Blog Archives

Recursive CTE for Dates In A Year

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.

Posted in CTE, CTE Book Tagged with: , , , , , , , ,

VARCHAR diff function

Last month I posted another CTE blog entry Using a CTE to Split a String Into Rows with Line Numbers.  Since then I have used it but, but realized that what I really needed was a diff tool to compare two

Posted in CTE Tagged with: , , , , , , ,

Using a CTE to Split a String Into Rows with Line Numbers

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

Posted in CTE, SQL 2008, SQL 2012 Tagged with: , , , , , ,

Using a CTE in a Function to Split Up a Database Connect String

I came across this example when preparing my CTE presentation for SQL Saturday in Portland OR in 2 weeks. Which produces the following output.

Posted in CTE Tagged with: , , , ,

Recursive CTE to Calculate Dates for the Last 30 Days

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

Posted in CTE Tagged with: , , , , ,

Using a CTE in a Function to Split Up a Query String

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

Posted in CTE Tagged with: , , , , ,

Using a CTE to Split a String Into Rows

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

Posted in CTE Tagged with: , , ,

CTE Hierarchy compared to the alternative

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

Posted in CTE, Performance, SQL Saturday Tagged with: , , , , , , ,

Newsletter Signup

Stay informed of Database Corruption Challenge events, and other things happening at SteveStedman.com with my newsletter.
Newsletter signup form.

Stedman Solutions

StedmanSolutionsRemoteSkilledDBA

Common Table Expressions Book

Paperback:

Kindle: