Created
June 6, 2019 18:40
-
-
Save morbidcamel101/e7201579d4d87f3c7450101b26edd3ce to your computer and use it in GitHub Desktop.
Generate a range of numbers for insersion SQL
This file contains 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 | |
@X INT = 1 | |
,@Y INT = 1000 | |
SELECT ones.n + 10*tens.n + 100*hundreds.n + 1000*thousands.n | |
FROM (VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) ones(n), | |
(VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) tens(n), | |
(VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) hundreds(n), | |
(VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) thousands(n) | |
WHERE ones.n + 10*tens.n + 100*hundreds.n + 1000*thousands.n BETWEEN @X AND @Y | |
ORDER BY 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment