Fundamentals of table expressions, Part 6 – Recursive CTEs
This article is the sixth part in a series about table expressions. Last month in Part 5 I covered the logical treatment of nonrecursive CTEs. This month I cover the logical treatment of recursive...
View ArticleParse parameter default values using PowerShell – Part 1
If you have ever tried to determine the default values for stored procedure parameters, you probably have marks on your forehead from hitting it on your desk repeatedly and violently. Most articles...
View ArticleParse parameter default values using PowerShell – Part 2
In my last post, I showed how to use TSqlParser and TSqlFragmentVisitor to extract important information from a T-SQL script containing stored procedure definitions. With that script, I left out a few...
View ArticleFundamentals of table expressions, Part 7 – CTEs, optimization considerations
This article is the 7th part of a series about named table expressions. In Part 5 and Part 6 I covered the conceptual aspects of common table expressions (CTEs). This month and next my focus turns to...
View ArticleParse parameter default values using PowerShell – Part 3
In part 1 and part 2 of this series, I introduced ParamParser: a PowerShell module that helps parse parameter information – including default values – from stored procedures and user-defined functions,...
View ArticleFundamentals of table expressions, Part 8 – CTEs, optimization considerations...
This article is the eighth part in a series about table expressions. So far I provided a background to table expressions, covered both the logical and optimization aspects of derived tables, the...
View ArticleThe challenge is on! Community call for creating the fastest number series...
In Part 5 of my series on table expressions I provided the following solution for generating a series of numbers using CTEs, a table value constructor and cross joins: DECLARE @low AS BIGINT = 1001,...
View ArticleNumber series generator challenge solutions – Part 1
Last month I posted a challenge to create an efficient number series generator. The responses were overwhelming. There were many brilliant ideas and suggestions, with lots of applications well beyond...
View ArticleNumber series generator challenge solutions – Part 2
This is the second part in a series about solutions to the number series generator challenge. Last month I covered solutions that generate the rows on the fly using a table value constructor with rows...
View ArticleNumber series generator challenge solutions – Part 3
This is the third part in a series about solutions to the number series generator challenge. In Part 1 I covered solutions that generate the rows on the fly. In Part 2 I covered solutions that query a...
View ArticleNumber series generator challenge solutions – Part 4
This is the fourth part in a series about solutions to the number series generator challenge. Many thanks to Alan Burstein, Joe Obbish, Adam Machanic, Christopher Ford, Jeff Moden, Charlie, NoamGr,...
View ArticleNumber series generator challenge solutions – Part 5
.warnHigh { color:#ff2200!important; } This is the fifth and last part in the series covering solutions to the number series generator challenge. In Part 1, Part 2, Part 3 and Part 4 I covered pure...
View ArticleFundamentals of table expressions, Part 9 – Views, compared with derived...
This is the 9th part in a series about named table expressions. In Part 1 I provided the background to named table expressions, which include derived tables, common table expressions (CTEs), views and...
View ArticleFundamentals of table expressions, Part 10 – Views, SELECT *, and DDL changes
As part of the series on table expressions, last month I started the coverage of views. Specifically, I started the coverage of logical aspects of views, and compared their design with that of derived...
View ArticleBucketizing date and time data
Bucketizing date and time data involves organizing data in groups representing fixed intervals of time for analytical purposes. Often the input is time series data stored in a table where the rows...
View ArticleSplit strings the right way – or the next best way
UPDATE: September 2nd, 2021 (Originally published July 26th, 2012.) A lot of things change over the course of a few major versions of our favorite database platform. SQL Server 2016 brought us...
View ArticleFundamentals of Table Expressions, Part 11 – Views, Modification Considerations
This article is the eleventh part in a series about table expressions. So far, I’ve covered derived tables and CTEs, and recently started the coverage of views. In Part 9 I compared views to derived...
View ArticleFundamentals of Table Expressions, Part 12 – Inline Table-Valued Functions
This article is the twelfth part in a series about named table expressions. So far I covered derived tables and CTEs, which are statement-scoped named table expressions, and views, which are reusable...
View ArticleFundamentals of Table Expressions, Part 13 – Inline Table-Valued Functions,...
This is the thirteenth and last installment in a series about table expressions. This month I continue the discussion I started last month about inline table-valued functions (iTVFs). Last month I...
View ArticleMatching Supply With Demand Challenge
My friend Peter Larsson sent me a T-SQL challenge involving matching supply with demand. As far as challenges go, it's a formidable one. It's a pretty common need in real life; it's simple to describe,...
View Article