递归方法 使用sql查询生成开始到结束日期之间的所有日期

来源:互联网 发布:淘宝公司简介怎么写 编辑:程序博客网 时间:2024/06/05 20:14

declare @StartDate DATETIME = ‘2015/05/01’
declare @EndDate DATETIME =’2015/06/03’;

with cte as
(
select @StartDate dday
union all
select dday +1 from cte
where dday < @EndDate
)
select * from cte
option(maxrecursion 0)

0 0
原创粉丝点击