I tried using OPTION (MAXRECURSION 0) to create a list of dates. This seems unsupported. Is there any workaround?
EDIT to Explain what I really want to do:
I have 2 tables.
table1: int weekday, bool
table2: date-date, bool
I want to get the result: view1: date (all days here this year are here), available (from table2 or from table 1, if not in table2).
This means that I have to apply the date attachment on a weekday. I hope this explanation is understandable, because I actually use more tables with more fields in the query.
I found this code to generate recursion:
WITH Dates AS ( SELECT cast('2008-01-01' as datetime) Date UNION ALL SELECT Date + 1 FROM Dates WHERE Date + 1 < DATEADD(yy, 1, GETDATE()) )
source share