• ok .. replace the dates with variables and create a proc

    WITH mycte AS (SELECT cast ('2010-01-01' AS DATETIME) DateValue

    UNION ALL

    SELECT DateValue + 1

    FROM mycte

    WHERE DateValue + 1 < cast ('2011-01-01' AS DATETIME))

    SELECT

    year(datevalue) as [Year],

    month(datevalue) as [Month],

    day(datevalue) as [Day],

    datename(dw, DateValue) Weekday

    from mycte

    OPTION (MAXRECURSION 0)