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