isnull / coalesce

  • Hi, is there any big difference between

    isnull and coalesce? Thanks.

  • Coalesce could be used in place of isnull, and BOL points out that it can be used instead of a case statement. I think for ease of understanding if you're doing an isnull operation, use that function, and reserve coalesce for instances where you need all the functionality it offers.

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

  • SO may so no, but they are. ISNULL can only check one item for a null value and return a none null value. With COALESCE you can check multiple columns as null and return the first non-null value. This is great as it is like a multip-part case statement. Other than that COALESCE can be in place of ISNULL but not the other way around and since COALESCE can accept multiple values it must create an array in memory so has a higher memory overhead than ISNULL.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

  • Thank you very much. It's really helpful.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply