OPTION (MAXRECURSION n)
n
10
32767
0
CREATE PROCEDURE dbo.usp_GenerateDates @startdate DATETIME ,@enddate DATETIME AS BEGIN ;WITH DatesCTE(CurrentDate) AS ( SELECT @startdate AS CurrentDate UNION ALL SELECT DATEADD(day,1,CurrentDate) FROM DatesCTE WHERE CurrentDate < @enddate ) SELECT CurrentDate FROM DatesCTE OPTION (MAXRECURSION 0) END