For a background, see the resolution to https://connect.microsoft.com/SQLServer/feedback/details/546437/coalesce-subquery-1-may-return-nullThe topic for coalesce starts off with: Returns the first nonnull expression among its arguments.This statement is inaccurate, and gives false promises. A correct summary would be: Evaluates the arguments in order and returns the current value of the first expression that initially does not evaluate to NULL.Later in the topic is the sentence, it says: ISNULL and COALESCE though equivalent, can behave differently.This is grossly confusing. They are certainly not equivalent. A better description is that they serve a similar purpose, but they are of very different nature. isnull() is a function, coalesce is a shortcut for the CASE expression given in the topic. The word equivalent is used here as well, but again this is not the best word. It would be better to say that coalesce is a syntactic shortcut.Most of all the topic should include a discussion that if you have something like: coalesce(<subquery>, 0)This can return NULL under READ COMMITTED in a multi-user environment, since the subquery is evaluated twice. The topic could also say that if this undesirable, isnull() is a better alternative.Similar notes can be made in the topic on nullif().
Product Language
Version
Category
Operating System
Operating System Language
Steps to Reproduce
Actual Results
Expected Results
Platform
Virtualization