How can I get all the dates between two dates?
I have a variable @MAXDATE which is storing the maximum date from the table. Now I want to get the all dates between @Maxdate and GETDATE() and want to store these dates in a cursor.
So far I have done as follows:
;with GetDates As  
(  
    select DATEADD(day,1,@maxDate) as TheDate
    UNION ALL  
    select DATEADD(day,1, TheDate) from GetDates  
    where TheDate < GETDATE()  
)  
This is working perfectly but when I am trying to store these values in a cursor
SET @DateCurSor = CURSOR FOR
                SELECT TheDate
                FROM GetDates
Compilation Error
Incorrect syntax near the keyword 'SET'.
How to solve this?