SDU Tools: Table of Numbers in SQL Server T-SQL

For anyone who’s worked with SQL Server for a long time, you’ll know that one of the common requests is that a table of numbers would be useful. Yes, just a table with 1, 2, 3, 4 and so on. Often in a query, you need just a certain set of values.
In our free SDU Tools, we’ve added a function to do that in a reasonably efficient way.
In the main screenshot, you can see it in use. We made it a little more flexible in that you can specify the starting number, and then specify the number of numbers.
Because we’ve done this with a recursive function, if you need to output more than 100 values, it’s important to add a MAXRECURSION option into the query like this:
We hope you find it useful. You can see it in action here:
For more information on joining our insiders team to get all our free tools and resources, follow the link here:
http://sdutools.sqldownunder.com
2018-04-18