title: Generate a resultset of incrementing dates in TSQL
body: <p>Consider the need to create a resultset of dates. We've got start and end dates, and we'd like to generate a list of dates in between.</p>
  
  <pre><code>DECLARE  @Start datetime
           ,@End  datetime
  DECLARE @AllDates table
          (@Date datetime)
  
  SELECT @Start = 'Mar 1 2009', @End = 'Aug 1 2009'
  
  --need to fill @AllDates. Trying to avoid looping. 
  -- Surely if a better solution exists.
  </code></pre>
  
  <p>Consider the current implementation with a <code>WHILE</code> loop:</p>
  
  <pre><code>DECLARE @dCounter datetime
  SELECT @dCounter = @Start
  WHILE @dCounter &lt;= @End
  BEGIN
   INSERT INTO @AllDates VALUES (@dCounter)
   SELECT @dCounter=@dCounter+1 
  END
  </code></pre>
  
  <p><strong>Question:</strong> How would you create a set of dates that are within a user-defined range using T-SQL? Assume SQL 2005+. If your answer is using SQL 2008 features, please mark as such.</p>