SQL Server : Print 1 – 100 using recursive CTE

The query below print numbers from 1 to 100 using recursive CTE.

with cte(N) as
(
select 1 as N
union all
select cte.N + 1
from cte
where cte.N <100
)
select * from cte

Advertisements