declare @startDay smalldatetime ='2013-01-01'
;with cte as(
select @startDay as d
union all
select DATEADD(d,1,d) as d
from cte
where d<'2019-05-01'
)
select * from cte
--设置循环次数,0为无限制
OPTION(MAXRECURSION 0)
2024-03-09 11:13:05
declare @startDay smalldatetime ='2013-01-01'
;with cte as(
select @startDay as d
union all
select DATEADD(d,1,d) as d
from cte
where d<'2019-05-01'
)
select * from cte
--设置循环次数,0为无限制
OPTION(MAXRECURSION 0)