• Nice question, thanks also Oleg's script looks great. Here is something that has the same result:

    DECLARE @dtFrom DATETIME

    DECLARE @dtTo DATETIME

    SET @dtFrom = '2010-01-01T00:00:00.000'

    SET @dtTo = '2010-12-31T00:00:00.000'

    DECLARE @Diff INT

    SET @Diff = DATEDIFF(DAY, @dtFrom, @dtTo)

    CREATE TABLE

    #Dates

    (

    [Date] DATETIME NOT NULL PRIMARY KEY,

    [SomeValueForDate] INT NOT NULL

    )

    CREATE TABLE #Digits(digit INT NOT NULL PRIMARY KEY);

    INSERT INTO #Digits(digit)

    VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);

    SELECT DATEADD( DAY, D3.digit * 100 + D2.digit * 10 + D1.digit , @dtFrom) AS n

    FROM

    #Digits AS D1

    CROSS JOIN #Digits AS D2

    CROSS JOIN #Digits AS D3

    WHERE

    D3.digit * 100 + D2.digit * 10 + D1.digit <= @Diff

    ORDER BY n;

    DROP TABLE #Digits

    DROP TABLE #Dates