SELECT Number N FROM master..spt_values WHERE TYPE='P'
DECLARE @Tally TABLE ( Number int)DECLARE @ThisNum intSET @ThisNum = 0WHILE @ThisNum < 10000 BEGIN INSERT INTO @Tally(Number) VALUES(@ThisNum) SET @ThisNum = @ThisNum + 1END
--==== cteTally With e1 (n) As ( --=== Create Ten 1's Select 1 Union All Select 1 Union All Select 1 Union All Select 1 Union All Select 1 Union All Select 1 Union All Select 1 Union All Select 1 Union All Select 1 Union All Select 1) , e2 (n) As (Select 1 From e1 a, e1 b) , e3 (n) As (Select 1 From e2 a, e2 b) , cteTally(n) As (Select row_number() over(Order By (Select n)) From e3) Select * From cteTally;