Created
January 25, 2016 16:10
-
-
Save ststeiger/db76b7f3c2fc87367a5b to your computer and use it in GitHub Desktop.
Create a number series in SQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DECLARE @start int | |
| DECLARE @end int | |
| SET @start = 3 | |
| SET @end = 4 | |
| ;WITH CTE AS | |
| ( | |
| SELECT @start AS zahl | |
| WHERE @start <= @end | |
| UNION ALL | |
| SELECT zahl + 1 AS zahl FROM CTE | |
| WHERE zahl < @end | |
| ) | |
| SELECT * | |
| FROM CTE | |
| OPTION (MAXRECURSION 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment