What are the practical differences between COALESCE() and ISNULL(,”)?

Technology CommunityCategory: T-SQLWhat are the practical differences between COALESCE() and ISNULL(,”)?
VietMX Staff asked 3 years ago
  • COALESCE() – Evaluates the arguments in order and returns the current value of the first expression that initially does not evaluate to NULL.
  • ISNULL() – Replaces NULL with the specified replacement value.

The ISNULL function and the COALESCE expression have a similar purpose but can behave differently:

  • COALESCE() is in the SQL ’92 standard and supported by more different databases. If you go for portability, don’t use ISNULL.
  • COALESCE() can have multiple inputs and it will evaluate in order until one of them is not null such as COALESCE(Col1, Col2, Col3, ‘N/A’). It’s recommended to use this by MS instead of ISNULL()
  • ISNULL() can only have one input, however it’s been shown to be slightly faster than COALESCE.