• Michael Valentine Jones (3/27/2012)


    dwain.c (3/26/2012)


    Jeff,

    The following thought occurred to me last night but I didn't get a chance to test it until this morning.

    Isn't the modulo function designed to always return a positive integer?

    Hence, in this part of your data generator, I don't believe you need to use ABS:

    SomeRandomInteger = CHECKSUM(NEWID()) % @Range + @StartValue

    I didn't try it for a million rows but the first 200 came up all as positives.

    It's pretty easy to show that the modulus operator will return a negative number:

    select x = -1111%100

    Results:

    x

    -----------

    -11

    Gosh. I'm not sure how I missed Dwain's question. Thanks for the cover, Michael.

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