• Sigerson (8/29/2013)


    Doing all of that within one SQL statement or a With block is beyond me,...

    It's beyond me, too. But then again, I wouldn't even try to do it with a single statement. Avoiding the loop or doing something "set based" does [font="Arial Black"]NOT [/font]mean doing it "within one SQL statement or a Withblock". Multiple set-based passes will be much faster than using a loop for this.

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