I need to create a function that returns a table of continuous dates. I would have gone in a minute and a maximum.
I expect him to be able to be called that:
SELECT * FROM GetDates('01/01/2009', '12/31/2009')
I currently have a stored process that does this, but the requirements are changing, and now I need to include the returned data from the union:
with mycte as
(
select cast(@minDate as datetime) DateValue
union all
select DateValue + 1
from mycte
where DateValue + 1 <= @maxDate
)
select DateValue
from mycte
option (maxrecursion 1000)
The problem, however, is that I need to set the recursion to more than 100. According to a post by Gail Erickson [MS] on eggheadcafe , this is not currently supported.
Without creating a real (non-temporary) table with only the date in it, is there a way to do this?
I am using SqlServer2005.