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 »

Last year while working on my CTE presentation for a SQL Saturday I added a blog post called “Using a CTE to Split a String Into Rows“, and since that posting I have used it many times. But as things go in development, eventually there is a need to do something more. Doing some complex string building to create files …

Using a CTE to Split a String Into Rows with Line Numbers 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 »

Thanks to everyone who attended my CTE presentation at SQL Saturday in Olympia Washington today.   Have a great rest of the day.  As promised I have posted the slides and sample TSQL queries here.  If you have any questions, please get in touch with me on Twitter  @SqlEmt  Remember to follow me on Twitter to stay informed of future presentations. Download the Presentation Here: Unleashing …

Unleashing CTEs in SQL Server – Slides and Sample Code – Olympia SQL Saturday 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 CTE, where 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 »

One of the common questions that comes up in my CTE class/presentation asks can you use the CTE inside of a function or stored procedure. The answer is yes, but today I came across another question, how can I split a string (varchar) into rows. I did some searching but didn’t find quite what I was looking for. I did …

Using a CTE to Split a String Into Rows Read more »

One of the common questions that I get asked after my Unleashing CTE Presentation is “Can we use CTEs in SSRS reports?” The answer is YES, Common Table Expressions work great in SSRS reports, one of my favorite ways of cleaning up some of those big ugly SSRS report queries is to use CTEs.

After my CTE presentation at SQL Saturday 108 in Redmond, I was asked many questions, and received several great suggestions from people.  Based on that feedback, I am updating my presentation for SQL Saturday 114 in Vancouver to include some additional content. One question was how does the performance compare between a recursive CTE to generate a hierarchical tree path …

CTE Hierarchy compared to the alternative Read more »