• ChrisM@Work (10/21/2014)


    Wouldn't it be easier and more natural to refactor this as a function?

    I agree but to return a random number, you'd probably want to use a GUID as the random seed. I'm pretty sure than NEWID() still isn't allowed in a function in 2012 but you could always use the "VIEW" trick to get a GUID.

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