• I agree with many of the others. This is a "hidden" performance problem that a lot of people don't even consider because they don't know about things like data-type precedence. It's one of the primary reasons why some folks think Tally Table functions are slow and why some cursors appear to be faster than certain setbased queries.

    Very well done, DC... this should be required reading not only for those learning SQL, but for those teaching it, as well.

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