Get Sequence of Numbers Using CTE (Common Table Expression)
Declare @From bigint ,@to bigint
Select @From =10 ,@To =100 ;
With CTE(Number)as
(Select @From
union all
select Number+1
from CTE
where Number<@to
)
select Number From CTE
option (maxrecursion 0)
Result:
Number
10
11
12
13
14
15
.
.
.
.
.
.
92
93
94
95
96
97
98
99
100
Babak
#SQL #SQLServer #CTE #common table expression #Number #Numbers #Sequence #Between #With
2/11/2014 10:56:27 AM