Home Forums SQL Server 2008 SQL Server 2008 - General Creating Rows Between Dates In A Single SQL Statement RE: Creating Rows Between Dates In A Single SQL Statement
Bill Talada
SSChampion
Points: 11954
More actions
April 21, 2015 at 1:32 pm
#1792553
declare
@StartDate date = '2015-01-01',
@EndDate date = '2015-01-05'
;
SELECT dateadd(DAY, x.rn, @StartDate)
FROM
( SELECT (ROW_NUMBER() OVER(ORDER by object_id))-1 AS rn FROM sys.objects) AS x
WHERE
x.rn <= DATEDIFF(DAY,@StartDate,@enddate )