In this post, I’ll explain how to use the NVL function in SQL Server.
NVL is a function available in Oracle; it receives a value; if this value is NULL, then NVL will return a second argument.
How to use it in SQL Server.
In SQL Server, you have a function with the same behavior called NULLIF. It receives two arguments and returns the second one when the first one is NULL.
COALESCE vs NULLIF.
You can get the same result using COALESCE. The only difference between COALESCE and NULLIF is COALESCE supports more than a second value; it will take the first, not-null value. If you are working with different SQL dialects in the same project, COALESCE is a better alternative; if you want a ubiquitous language in your queries, several SQL dialects support it.