[ACCEPTED]-Create Temp Table with Range of Numbers-sql-server-2008
Accepted answer
WITH q AS
(
SELECT startId, endId
FROM ranges
UNION ALL
SELECT startId + 1, endId
FROM q
WHERE startId < endId
)
SELECT startId
FROM q
OPTION (MAXRECURSION 0)
0
In MSSQL, you can also use select from any 3 arbitrary large table, syscolumns would 2 be an example. If there are not enough rows 1 - you can do a cross join:
SELECT TOP 10000
ROW_NUMBER() OVER (ORDER BY c1.id)
FROM syscolumns AS c1
CROSS JOIN syscolumns AS c2
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.