FREE SQL Server Common Table Expressions Book PDF – by Steve Stedman You get full access to my Common Table Expressions book, along with sample code to support the queries shown in the book. You can download this as a PDF and start reading today. Over 250 pages of content all about TSQL and Common Table Expressions. Once you have …

CTE Book Read more »

My Common Table Expression presentation was accepted for SQL Saturday 212 in Redmond WA. This is the session that I am the most familiar with, and that I have presented the most times. I think this will be the 8th time I have presented this session, and after every previous presentation it has been improved. Over the last several months …

Common Table Expression accepted for SQL Saturday 212 in Redmond WA Read more »

For more information on Common Table Expessions and performance, take a look at my book at Amazon.com: Common Table Expressions Joes 2 Pros®: A CTE Tutorial on Performance, Stored Procedures, Recursion, Nesting and the use of Multiple CTEs There are many reasons that a Temp Table, Table Variable or Common Table Expression can be a good solution, but there is …

Temp Table vs Table Variable vs CTE and the use of TEMPDB. Read more »

Other SQL Server CTE Material, Posts, and Samples On This Site CTE Hierarchy compared to the alternative Recursive CTE’s Calculating Factorials with a Recursive CTE Fibonacci Sequence CTE – With An Insert Statement Generating a Tree Path with a CTE CTE Query Performance Multiple CTE’s in a single Query Recursive CTE’s CTE Category on this site CTE Tag on this …

Common Table Expressions Read more »

Other SQL Server CTE Material, Posts, and Samples On This Site CTE Hierarchy compared to the alternative Recursive CTE’s Calculating Factorials with a Recursive CTE Fibonacci Sequence CTE – With An Insert Statement Generating a Tree Path with a CTE CTE Query Performance Multiple CTE’s in a single Query Recursive CTE’s CTE Category on this site CTE Tag on this …

Common Table Expressions (CTE) Read more »

This week marks my 7th anniversary of Stedman Solutions, LLC being my full time job and my primary source of income. It also happens to be the 7th anniversary of the last time I got fired. What’s happened over 7 years? Grew the team from 0 to 1, and eventually to 5 and still growing.   Database Corruption Challenge in 2015. …

Seven Years at Stedman Solutions. Read more »

Have you ever needed to generate a list of dates for the last 30 days.  There are lots of different ways to do this with TSQL, but one way is with a recursive CTE. You can then left join against it with another query to generate a list of all  dates in a result set, along with the dates for …

Recursive CTE to Calculate Dates for the Last 30 Days Read more »

The question came up as to how do I parse a query string using TSQL.  So here you go, using a common table expression, and basing this on a similar function to what I put together yesterday for split. which produces this output. A quick and easy way to parse a query string  in TSQL using a CTE. Receive a …

Using a CTE in a Function to Split Up a Query String Read more »

After my CTE presentation a while back I was asked many questions, and received several great suggestions from people.   One question was how does the performance compare between a recursive CTE to generate a hierarchical tree path listing and a query using self JOINs and UNION ALL to generate similar results.  To test this I created a simple table …

CTE Hierarchy compared to the alternative Read more »

by Steve Stedman and the Stedman Solutions Team Database Corruption vs Drive Failure Explained Thu, 25 Mar 2021 If you don’t know the difference between server corruption and drive failure then this video is for you. It will all be explained in this quick 6 min video. Transcription: Steve Stedman 0:10Now, one of the things that when w Read more… …

End of the Month Blog Post Wrap-up Read more »