• This is almost a duplicate of the question you posted at the following URL...

    http://www.sqlservercentral.com/Forums/Topic1385878-392-1.aspx

    ... and it has been answered there, as well.

    Having multiple posts on the same question only serves to divide the answers of the responders. For anyone that cares to respond, please respond to the post above so we can keep all of the answers together. Thanks.

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