• I agree with that whole heartedly, DC. I've found that a well written cursor will frequently beat a home grown While Loop just as you said. I'll also add that I think of While Loops as nothing more than "home grown cursors" and have resorted to calling them "cursors" even though that's probably a bit confusing to most. Based on that, allow me to correct what I said in the post previous to this one just to be clear... there are exceptions to every rule but all forms of RBAR (not just cursors) should be avoided if possible. I'll also add that, given a little thought, it's usually possible to avoid them without resorting to just another form of RBAR.

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