tag:blogger.com,1999:blog-3000721125799986885.post1570382705539519347..comments2024-03-28T04:05:20.028-07:00Comments on SELECT Blog FROM Brad.Schulz CROSS APPLY SQL.Server(): CTE: Coolest T-SQL EnhancementBrad Schulzhttp://www.blogger.com/profile/01852762873611487368noreply@blogger.comBlogger16125tag:blogger.com,1999:blog-3000721125799986885.post-30574850957474878542024-01-14T22:28:56.969-08:002024-01-14T22:28:56.969-08:00I am very enjoyed for this blog. Its an informativ...I am very enjoyed for this blog. Its an informative topic. slotplayground.comhttps://www.slotplayground.comnoreply@blogger.comtag:blogger.com,1999:blog-3000721125799986885.post-60326942020050086192024-01-14T22:28:00.796-08:002024-01-14T22:28:00.796-08:00Thanks for sharing such a useful post.Thanks for sharing such a useful post.19guide03.comhttps://www.19guide03.comnoreply@blogger.comtag:blogger.com,1999:blog-3000721125799986885.post-84720411472626969092024-01-14T22:24:44.137-08:002024-01-14T22:24:44.137-08:00This has been a really wonderful post. Thanks for ...This has been a really wonderful post. Thanks for providing this info.메이저-토토사이트https://www.outlookindia.com/outlook-spotlight/2023년-11월-메이저-토토사이트-순위-추천-토토-안전놀이터-top15-news-332207noreply@blogger.comtag:blogger.com,1999:blog-3000721125799986885.post-38503350695720042432024-01-07T04:37:17.220-08:002024-01-07T04:37:17.220-08:00
Hello there thanks for sharing post that are help...<br />Hello there thanks for sharing post that are helpfulsportstotozonecomhttps://www.slotplayground.com/noreply@blogger.comtag:blogger.com,1999:blog-3000721125799986885.post-74853131295440721482021-10-24T02:27:48.626-07:002021-10-24T02:27:48.626-07:00Thanks for the great content Sir, I wil also share...Thanks for the great content Sir, I wil also share with my friends & onece again thanks a lot.<br /><a href="https://bloggingenterpro.blogspot.com/2021/07/%20Seo%20optimization%20Seo%20Ready%20Best%20Responsive%20Blogger%20Template-FlatMag.html" rel="nofollow">Seo optimization (Seo Ready) Best Responsive Blogger Template FlatMag</a><br /><a href="https://bloggingenterpro.blogspot.com/2021/07/how%20to%20get%20traffic%20to%20a%20new%20blog.html" rel="nofollow">how to increase blog traffic fast</a><br /><a href="https://bloggingenterpro.blogspot.com/2021/10/how-to-remove-realme-c3-frp-bypass-2021.html?m=1" rel="nofollow">remove realme c3 frp bypass 2021</a><br /><a href="https://bloggingenterpro.blogspot.com/2021/07/how-to-add-twitter-cards-meta-tags-to.html" rel="nofollow">How To optimize Twitter Meta Tags in Blogger Update -2021</a>Tech Engineer BDhttps://www.blogger.com/profile/07152133544255560132noreply@blogger.comtag:blogger.com,1999:blog-3000721125799986885.post-66305330701048181432021-07-17T19:51:06.259-07:002021-07-17T19:51:06.259-07:00You ought to be a part of a contest for one of the...You ought to be a part of a contest for one of the finest blogs online. I'm going to highly recommend this web site! <a href="https://site-4369653-8068-9650.mystrikingly.com/" title="사설토토" rel="nofollow">사설토토</a><br /><br />totopickprohttps://60a1e19c870ea.site123.me/blog/tic-tac-toenoreply@blogger.comtag:blogger.com,1999:blog-3000721125799986885.post-54457018146493017642012-01-30T02:14:49.740-08:002012-01-30T02:14:49.740-08:00This comment has been removed by a blog administrator.johnhttps://www.blogger.com/profile/04643521875190227873noreply@blogger.comtag:blogger.com,1999:blog-3000721125799986885.post-16770244384555947672012-01-29T23:48:32.367-08:002012-01-29T23:48:32.367-08:00This comment has been removed by a blog administrator.Madhuri Naiduhttps://www.blogger.com/profile/05034281192896528323noreply@blogger.comtag:blogger.com,1999:blog-3000721125799986885.post-76129877515029228552011-12-05T20:46:37.537-08:002011-12-05T20:46:37.537-08:00This comment has been removed by a blog administrator.Android apps developerhttp://clawdigital.com/android-app-developmentnoreply@blogger.comtag:blogger.com,1999:blog-3000721125799986885.post-3238537362085420692011-09-22T10:35:42.258-07:002011-09-22T10:35:42.258-07:00Your DST example seems rather complex and hard to ...Your DST example seems rather complex and hard to follow, even the CTE version. As an example of what you can do with CTE's it may be fine but for actually finding the values it seems rather out of the way.<br /><br />I wrote my own method using CROSS APPLY that may be useful to some people:<br /><br />SELECT<br /> S.Now,<br /> DST.*,<br /> CONVERT(BIT, CASE<br /> WHEN S.[Now] >= DST.StartDate AND S.[Now] < DST.EndDate THEN 1<br /> ELSE 0<br /> END) AS IsDST<br />FROM<br /> (SELECT GETDATE() AS [Now]) S<br /> CROSS APPLY<br /> (<br /> SELECT<br /> CONVERT(VARCHAR(4), DATEPART(Year, [Now])) AS DSTYear<br /> ) AS DSTSource<br /> CROSS APPLY<br /> (<br /> SELECT<br /> CONVERT(DATETIME, DSTYear + '-03-08 02:00:00.000') AS MarchStartDate,<br /> CONVERT(DATETIME, DSTYear + '-11-01 02:00:00.000') AS NovStartDate<br /> ) AS DSTPrep<br /> CROSS APPLY<br /> (<br /> SELECT<br /> MarchStartDate + CASE DATENAME(WEEKDAY, MarchStartDate)<br /> WHEN 'Monday' THEN 6<br /> WHEN 'Tuesday' THEN 5<br /> WHEN 'Wednesday' THEN 4<br /> WHEN 'Thursday' THEN 3<br /> WHEN 'Friday' THEN 2<br /> WHEN 'Saturday' THEN 1<br /> WHEN 'Sunday' THEN 0<br /> END AS StartDate,<br /> <br /> NovStartDate + CASE DATENAME(WEEKDAY, NovStartDate)<br /> WHEN 'Monday' THEN 6<br /> WHEN 'Tuesday' THEN 5<br /> WHEN 'Wednesday' THEN 4<br /> WHEN 'Thursday' THEN 3<br /> WHEN 'Friday' THEN 2<br /> WHEN 'Saturday' THEN 1<br /> WHEN 'Sunday' THEN 0<br /> END AS EndDate <br /> ) AS DSTTechJoshhttps://www.blogger.com/profile/11039850964477323086noreply@blogger.comtag:blogger.com,1999:blog-3000721125799986885.post-28291604010630702942011-05-11T14:30:47.034-07:002011-05-11T14:30:47.034-07:00@Sven:
Thanks for mentioning that... I know it al...@Sven:<br /><br />Thanks for mentioning that... I know it all too well... I talked about that in my recursion post a year ago:<br /><br />http://bradsruminations.blogspot.com/2010/03/this-article-on-recurson-is-entitled.html<br /><br />--BradBrad Schulzhttps://www.blogger.com/profile/01852762873611487368noreply@blogger.comtag:blogger.com,1999:blog-3000721125799986885.post-29012908808242584692011-05-11T14:16:15.457-07:002011-05-11T14:16:15.457-07:00Don't reference the same cte multiple times in...Don't reference the same cte multiple times in one query. This kind of query tends to be very handy in some situations, for example in a union select. <br /><br />;with cte_stuff as (select foo from bar) <br />select *<br /> from table<br /> join cte_stuff as c1 on c1.column1 = table.somecolumn<br />union all select *<br /> from table<br /> join cte_stuff as c2 on c2.column2 = table.someothercolumn<br /><br />Try to avoid this. The cte query gets parsed and executed twice. As mentioned, Mssql currently cannot spool cte results and use them multiple times. If you use big tables, performance may be an issue.Svenhttps://www.blogger.com/profile/00544160655209234895noreply@blogger.comtag:blogger.com,1999:blog-3000721125799986885.post-28886293388363072052011-05-11T09:51:31.278-07:002011-05-11T09:51:31.278-07:00Way to cover the gambit again. I also like the ti...Way to cover the gambit again. I also like the tie-in to last months TSQL2sday.Jasonhttps://www.blogger.com/profile/03156682047225926878noreply@blogger.comtag:blogger.com,1999:blog-3000721125799986885.post-47032663732035087032011-05-10T19:21:06.965-07:002011-05-10T19:21:06.965-07:00Those are some great examples, Brad! Thank you so...Those are some great examples, Brad! Thank you so much for contributing to T-SQL Tuesday!Bob Pusaterihttp://www.bobpusateri.comnoreply@blogger.comtag:blogger.com,1999:blog-3000721125799986885.post-69253691917655239552011-05-10T16:11:42.440-07:002011-05-10T16:11:42.440-07:00@Naomi:
Thanks!
Funny's too hard... I only...@Naomi:<br /><br />Thanks! <br /><br />Funny's too hard... I only try to do that if I'm really ambitious or have the time. For this post, I just quickly scraped something together this morning.<br /><br />--BradBrad Schulzhttps://www.blogger.com/profile/01852762873611487368noreply@blogger.comtag:blogger.com,1999:blog-3000721125799986885.post-33085595055516545832011-05-10T16:03:46.106-07:002011-05-10T16:03:46.106-07:00Very interesting, thanks! Not as funny as usual, t...Very interesting, thanks! Not as funny as usual, though :)Naomihttps://www.blogger.com/profile/14349415198731303848noreply@blogger.com