• BluePeter - Thursday, August 9, 2018 2:20 AM

    Rather use a recursive cte to create your numbers.

    WITH cte AS (
       SELECT 1 as Num
       UNION ALL
       SELECT Num + 1 FROM cte  WHERE Num < 52
        )
    SELECT * FROM cte

    This method works well for populating Calendar tables, too.

    But if you insist on using an existing table, sys.columns is just about guaranteed to always have enough entries.

    Be careful here, the recursive CTE is much slower than the inline tally table CTE method I posted, strongly advice against using a recursive CTE for this purpose.
    😎