Louis Davidson needs even more sequential numbers:
I thought I was done, nice quick little throwaway piece, but I went a little more in depth than I planned. Then Aaron Bertrand messaged me about a post that I had forgotten (even if I did edit it :)), where he was introducing
GENERATE_SERIES(GENERATE_SERIES: My new go-to to build sets). In it, he had included a method of doing this using a method that replicates digits and then usesSTRING_SPLITandROW_NUMBERto generate more digits. He also noted that it was blistering fast.Aaron (if you know him) is rarely wrong about SQL (at the very least).
I also realized there was one other thing I wanted to add to my tests, that being just selecting from a Numbers/Tally table that has a billion rows. This should be the fastest way to pull a set of numbers.
Read on for one hundred million results. And check out Brent Ozar’s comment on getting things in descending order.