Thursday, December 20, 2012

How to get date range in a list table using T-SQL (sql server)

How to get date range in a list table using T-SQL (sql server)


declare @a as datetime

declare @b as datetime

set @a = '2012-02-21'
set @b = '2012-09-11';


with cte(A) as
(
select @a A
union all
select DateAdd(day,1,A) A from cte where A<@b
)

SELECT * FROM cte
option (maxrecursion 3660);

No comments: