• Part of my point here is to turn the OP to the direction of tally tables also.

    I purposely have asked him to look at them.

    Here is a simple way to create a Tally Table (Shamelessly copied from Jeff's article).

    --=============================================================================

    -- Create and populate a Tally table

    --=============================================================================

    --===== Conditionally drop and create the table/Primary Key

    IF OBJECT_ID('dbo.Tally') IS NOT NULL

    DROP TABLE dbo.Tally

    CREATE TABLE dbo.Tally

    (N INT,

    CONSTRAINT PK_Tally_N PRIMARY KEY CLUSTERED (N))

    --===== Create and preset a loop counter

    DECLARE @Counter INT

    SET @Counter = 1

    --===== Populate the table using the loop and couner

    WHILE @Counter <= 11000

    BEGIN

    INSERT INTO dbo.Tally

    (N)

    VALUES (@Counter)

    SET @Counter = @Counter + 1

    END

    http://www.sqlservercentral.com/articles/TSQL/62867/[/url]

    How To Post[/url]