• Koen Verbeeck (2/2/2012)


    SQL Kiwi (2/2/2012)


    An article about clearly documented behaviour, and no mention of the more serious problems with COALESCE? Poor.

    Now you make me curious. Which issues are you referring to? A quick Google search tells me that datatype precedence is important for COALESCE.

    SELECT COALESCE((SELECT CASE WHEN RAND() <= 0.5 THEN 999 END), 999);

    SELECT ISNULL((SELECT CASE WHEN RAND() <= 0.5 THEN 999 END), 999);

    https://connect.microsoft.com/SQLServer/feedback/details/546437/coalesce-subquery-1-may-return-null

    https://connect.microsoft.com/SQLServer/feedback/details/336002/unnecessarily-bad-performance-for-coalesce-subquery