The following is chapter 4 from my Common Table Expressions book in its entirety. READER NOTE: Please run the CTEBookSetup.sql script in order to follow along with the examples in this chapter. The script mentioned in this chapter is available at http://SteveStedman.com. Recursive CTEs Have you ever solved a maze puzzle on paper, or had the opportunity to visit a …

Recursive CTEs Read more »

During my 24 Hours of Pass presentation on Advanced CTE’s today I was asked the question about deleting from a CTE when it uses an EXISTS statement that queries another table. I figured I would create quick blog post to show the example. First some background when using the delete statement with a CTE you can’t delete if the query inside …

Deleting from a CTE with an EXISTS statement Read more »

Today I am presenting on Advanced Common Table Expressions as part of the 24 Hours of PASS conference. It is being webcast so check it out if you can. The outline for the presentation will be the following: Recursive Queries Hierarchical Recursive Data Manipulating Data Common Use Cases CTE Performance Considerations Classic Recursive Algorithms The sample code and slides are …

24 Hours of PASS – Advanced CTE Presenation Read more »

On Wednesday June 24th at 6:00pm pacific time or( 25 Jun 2015 01:00 GMT ) will be speaking at the 24HOP (24 Hours of Pass) conference which is broadcast online. I will be presenting on Advanced Common Table Expressions, and it is going to be fun.   Here is the session abstract. You have been introduced to Common Table Expression, you understand …

Advanced Common Table Expressions – 24 Hours of PASS Read more »

There is a lot happening right now, so I thought I would put together a brief overview of upcoming speaking engagements. May 13th – When Corruption Strikes (PASS DBA Virtual Chapter Meeting) May 16th – Exploring SQL Server Join Types – INNER, OUTER, and much more… (SQL Saturday Redmond) June 9th –  When Corruption Strikes 2 (HADR Virtual Pass Chapter) June …

Upcoming Speaking Engagements Read more »

The free SQL Server Queries weekly training is being presented by Steve Stedman. The training is being presented by Aaron Buma and myself. This week we are covering two topics, first the MERGE statement will be covered by Aaron, then I will present on Recursive Queries. There MERGE statement is one of those that I was not familiar enough with when …

Weekly SQL Training – MERGE Statement and Recursive Queries Read more »

Here is a short video that shows how to convert those ugly derived table (SubQuery) queries into a common table expression to help clean up your TSQL code. This applies to Common Table Expressions on Microsoft SQL Server, and the recording comes from my Free SQL Query Training course.     Other CTE Related Posts: Writing Your First Common Table Expression …

Using a Common Table Expression Instead of a Derived Table Read more »

I just a added a video to YouTube titled “What is a Common Table Expression”.  This video covers the extreme basics of what a CTE is on Microsoft SQL Server, and how to write that CTE in TSQL. Here is the video: It’s a very short video with the basics of what a CTE is.  Take a look.   Other …

What is a Common Table Expression Read more »

The SQL Training was a lot of fun this week we covered Top, Ranking, NTILE, and Analytic functions in preparation for the Microsoft 70-461 exam. Next week Aaron Buma and I will be presenting Set Operators, Derived Tables and CTEs. The live session will be with Google On Air Broadcasts Thursday Feb 12th at 9:00am (pacific). This is a FREE SQL Training …

SQL Query Training – Next Week – Set Operators, Derived Tables and CTEs Read more »