• Mike C (6/9/2009)


    Jeff Moden (6/9/2009)


    Mike C (6/9/2009)


    Another minor quibble - each instance of RAND() is invoked once per query.

    SELECT RAND(), RAND()

    Generates two different random numbers because RAND() is actually called twice. Each RAND() result is repeated for every row of the result set (in this case only one row).

    Heh... correct identification of the problem in 90% of the solution. We know the behavior and the work around. Use the work around.

    LOL Jeff. I wrote a chapter about 4 months ago that uses the CHECKSUM(NEWID()) method to generate "random" test data.

    Dang... sorry Mike. Based on what you wrote, I thought you were going to be one of those folks that didn't get it. After having read a book of yours, I was really surprised at you response here. I took it the wrong way.

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