• If you want a comma separated list of the numbers use a quirky update syntax (or a FOR XML, which performs better but is more complicated).

    Here the quirky update:

    DECLARE @Month DATETIME

    SELECT @Month = '2009-02-01'

    DECLARE @Ret VARCHAR(200)

    ; WITH

    t1 AS (SELECT 1 N UNION ALL SELECT 1 N), -- 2

    t2 AS (SELECT 1 N FROM t1 x, t1 y), -- 4

    t3 AS (SELECT 1 N FROM t2 x, t2 y), -- 16

    Tally AS (SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) N FROM t3 x, t3 y) -- 256

    SELECT

    @Ret = ISNULL(@Ret + ', ', '') + CONVERT(VARCHAR(4), N)

    --N

    FROM Tally

    WHERE

    N <= DATEDIFF(DAY, @Month, DATEADD(MONTH, 1, @Month))

    PRINT @Ret

    No real table, no storage, just numbers :hehe: