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 »

Day 5 of Common Table Expression Month (June) at SteveStedman.com, today I will cover concepts around the scope of a CTE. The queries in the video 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. Where is …

CTE Scope Read more »

Day 4 of Common Table Expression Month (June) at SteveStedman.com, today I will cover the topic of terminating the previous T-SQL statement. 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. To start with having …

Common Table Expressions – Terminating the Previous Statement Read more »

Day 3 of Common Table Expression Month (June) at SteveStedman.com, today I have a video presentation extracted from my normal SQL Saturday CTE presentation. The queries in the video 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 …

Video: Writing Your First CTE with SQL Server Read more »

Day 2 of Common Table Expression Month (June) at SteveStedman.com, today I will cover creating your very first CTE. Keep in mind that this may look a bit weird or strange at first, the syntax is different from anything you may have seen with SQL Server before, and there are some parts that are very similar. First lets take a …

Writing Your First Common Table Expression with SQL Server Read more »

This month is going to be Common Table Expressions Month at SteveStedman.com.   My goal is to post one valuable post on a Common Table Expressions topic each day for the entire month. What is a Common Table Expression A Common Table Expression (know as CTE) is a type of in memory result set, similar to a view or a …

Common Table Expression (CTE) Month at SteveStedman.com Read more »

In my Common Table Expressions presentation the topic of recursion often comes up, but for scalar functions in T-SQL, it might not be as common. This article has been written to show how a scalar function in SQL Server can call itself, thus being considered recursive. The example uses a recursive scalar function to calculate the Fibonacci sequence. What is …

Recursive Scalar Function in T-SQL Read more »

The article could be named, “How to use up all of your SQL Server available memory with a single CTE query.”  Another name for the article could just be “SQL Server Bug Report” depending on how you look at it. When presenting unleashing Common Table Expressions at SQL Saturday a while back, I was asked a couple of great questions …

SQL Server Memory Hog Query 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 »