• Please post the link that you mentioned so others can see what you have seen. Thanks.

    If you want to generate a million rows of sample data using those ratios, you could do the following. This takes about 1-1/2 seconds to gen a table with a million rows in it.

    WITH

    cteGenMillionNumbers AS

    (

    SELECT TOP 1000000

    N = ABS(CHECKSUM(NEWID()))%100+1

    FROM sys.all_columns ac1

    CROSS JOIN sys.all_columns ac2

    )

    SELECT SomeID= IDENTITY(INT,1,1),

    Grade = CASE

    WHEN N BETWEEN 1 AND 40 THEN 1

    WHEN N BETWEEN 41 AND 65 THEN 2

    WHEN N BETWEEN 66 AND 85 THEN 3

    WHEN N BETWEEN 86 AND 99 THEN 4

    WHEN N = 100 THEN 5

    ELSE 0 --will never happen but I do these types of safety checks

    END

    INTO #MyHead

    FROM cteGenMillionNumbers

    ;

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)