There’s been lots of awesome T-SQL improvements in SQL Server 2022. One of which is the new GENERATE_SERIES relational operator which allows us to generate a series of numbers within a given range.
The start and end values of the range and the step between them is configurable and can be any of the following types 👇🏻 …
- or numeric.
… but the start and end types must match.
In the below example we use GENERATE_SERIES to get numbers between 1 and 50 in steps of 5…
Another example below shows how to use GENERATE_SERIES to create a series of decimal values between 0.0 and 1.0 in steps of 0.1
SQL Server 2022 T-SQL demos on GitHub
Demos/SQL Server 2022 T-SQL Enhancements at main · kendalvandyke/Demos (github.com)