Transcription of Video: Let’s take a look at another recursive CTE. That’s not looking at tables, but it’s just looking at math. And here, we could create a recursive function that’s called sum of parts, and select from the sum of parts. Basically, we’re creating a function that selects from itself. And what it does is it says give me …

Looking at Math with Recursive CTE’s Read more »

Transcription of Video: One of the things I like play with is performance and pushing things to their limits. So what I want to do next is see how far can we push this sum of parts? Can we do the sum of parts for 40,000? With the option of Max recursion equaling 40,000? No, we cannot do that because …

Recursive CTE Examples Read more »

Transcription of Video: So here’s an example of building a recursive common table expression, I’m gonna start out with the with statement, we’re gonna call it department CTE. And we’re going to label the columns that we’re going to return department ID, the department, the parent, and those are all things we’ve seen before earlier in the presentation. And then …

Steve Explains how to build a Recursive CTE Read more »

Transcription of Video: Now on to recursive common table expressions. This is my favorite part. And this is where it gets really fun is working with recursive CTE’s. Because with recursive CTE, we’re doing things that are really difficult to do any other way with SQL Server. So, a CTE is considered recursive when the CTE references itself. It’s interesting, …

Steve’s Introduction to Recursive Common Table Expressions Read more »

Transcription of Video: Every recursive CTE needs an anchor query. And what an anchor query is, is it defines the start of the recursion. This is the part that cannot reference the CTE itself, it has to start with some base starting point. So if you’re doing a hierarchy of departments, well, you’re starting the recursion may be giving me …

Recursive CTE Terminology Read more »

Day 9 of Common Table Expression Month (June) at SteveStedman.com, today I will be building on the intro to recursive CTEs from two days ago and on showing how a recursive CTE can be used to calculate information about dates of the year from yesterday. This would be useful if you were trying to build a calendar. These queries will be using that database …

Expanding on Recursive Dates CTE Read more »

Day 8 of Common Table Expression Month (June) at SteveStedman.com, today I will be building on the intro to recursive CTEs from yesterday and showing how a recursive CTE can be used to calculate information about dates of the year. This would be useful if you were trying to build a calendar. These queries will be using that database that …

Recursive CTE for Dates In A Year Read more »

Day 7 of Common Table Expression Month (June) at SteveStedman.com, today we will be taking a look at the introduction to recursive CTEs. These queries will be using that database that was set up in a previous posting on the CTE_DEMO Sample Database, if you haven’t set up the sample database, download it and set it up now. The recursive feature …

Introduction to Recursive CTEs Read more »