• There is no need for the RBAR of a function to generate random integer values. The only reason you think so is because you found out that RAND returns the same number throughout a given single select. The following code produces 500 random integers from 10 to 100 across many rows in a single return as an example...

    DECLARE @MinValue INT , @MaxValue INT , @Quantity INT

    SELECT @MinValue = 10, @MaxValue = 100, @Quantity = 500

    SELECT TOP (@Quantity)

    ABS(CHECKSUM(NEWID()))%(@MaxValue-@MinValue+1)+@MinValue

    FROM Master.sys.SysColumns sc1

    --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)