Labels

Monday, January 28, 2013

SQL Query to get Number Range in Tabular format



DECLARE @Start INT, @End INT

SELECT  @Start = 0, @End = 100
;WITH Numbers AS (
     SELECT @Start Num
     UNION ALL
     SELECT Num + 1
     FROM Numbers
     WHERE Num < @End
)
SELECT  *
FROM    Numbers
OPTION (MAXRECURSION 0);


No comments:

Post a Comment