+2 votes
in Sql by
What are the practical differences between COALESCE() and ISNULL(,'')?

1 Answer

0 votes
by
  • 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.

Related questions

+2 votes
asked Jan 15, 2022 in Sql by GeorgeBell
+2 votes
0 votes
+2 votes
asked Jan 15, 2022 in Sql by GeorgeBell
...