Generar un conjunto de resultados de fechas incrementales en TSQL

Considere la necesidad de crear un conjunto de resultados de fechas. Tenemos fechas de inicio y finalización, y nos gustaría generar una lista de fechas intermedias.

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.

Considere la implementación actual con unWHILE lazo:

DECLARE @dCounter datetime
SELECT @dCounter = @Start
WHILE @dCounter <= @End
BEGIN
 INSERT INTO @AllDates VALUES (@dCounter)
 SELECT @dCounter=@dCounter+1 
END

Pregunta: ¿Cómo crearía un conjunto de fechas que están dentro de un rango definido por el usuario utilizando T-SQL? Supongamos SQL 2005+. Si su respuesta está utilizando las características de SQL 2008, marque como tal.

Respuestas a la pregunta(16)

Su respuesta a la pregunta