sql with 递归 查询特定区间日期

 

 

 

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)

posted @ 2014-04-14 12:07  Emrys5  阅读(449)  评论(0)    收藏  举报