• jonysuise (10/18/2013)


    Hi asranantha, 😀

    I would use COALESCE AND CASE, because it's SQL standard.

    I would use just ISNULL AND NULLIF (like Sean did) because you don't have unexpected datatype precedence problems with ISNULL like you can with COALESCE, is a tiny bit faster than COALESCE, takes fewer characters to type, and it ticks all sorts of people off that still think SQL is portable across engines. 😀

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