CTE BAQ to get incrementing numbers

@klincecum s query…

image

Works too.
image

4 Likes

… and half the execution time, too.

Firelight (Darkest London, #1) by Kristen Callihan | Goodreads

1 Like

Btw @Banderson , what you showed is what I actually use when I want to get rows.

PartTran has plenty, and easy to grab. It may have even been you that gave me the idea.

1 Like

I usually do it with dates. I can’t think of a time I ever actually need just a list of numbers.

1 Like

Ironically, dates are my foremost use case. Sometimes I want a daterange which includes all dates and my data has some gaps, and the latency penalty is magnitudes lower on SQL Server than on SSRS or Power Bi etc. I’ll generate a tally table and generate a daterange with dateadd off of those numbers.

But generating a tally off of 2^n nulls happens entirely in memory and never touches storage! Okay, fine, the optimizer is pretty dang aggressive about recognizing when it can ignore data and only glance at a rowindex, nevertheless, eww storage touching.

1 Like