Last active
December 28, 2015 22:46
-
-
Save jbnv/59d18bbef99d4bf89f64 to your computer and use it in GitHub Desktop.
Creates a table containing all integers between 0 and 2^20-1 inclusive. (Platform independent.)
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
CREATE TABLE Numbers | |
( | |
N INT NOT NULL, | |
CONSTRAINT PK_Numbers | |
PRIMARY KEY CLUSTERED (N) | |
WITH FILLFACTOR = 100 | |
) | |
INSERT INTO Numbers (N) | |
SELECT ROW_NUMBER() OVER(ORDER BY a.n,b.n,c.n,d.n,e.n,f.n,g.n,h.n,i.n,j.n) AS [N] | |
FROM ( SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3) a (n), | |
( SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3) b (n), | |
( SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3) c (n), | |
( SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3) d (n), | |
( SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3) e (n), | |
( SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3) f (n), | |
( SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3) g (n), | |
( SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3) h (n), | |
( SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3) i (n), | |
( SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3) j (n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not sure if
ROW_NUMBER() OVER()
is platform-independent or just SQL Server 2008 and later.