Coalesce is one of those old functions that has been around for a very long time and lost some of it’s lime light. It is good for a number of things but it’s VERY important to know how it behaves.
So coalesce takes any two or more parameters and takes the first parameter which IS NOT NULL and returns that value. For example:
SELECT COALESCE(null,’ ‘, ‘value’);
This would return the second argument, ‘ ‘, not the value ‘value’. You need to be very careful with this! Sometimes programmers don’t recognize the difference between null and empty values. If that is you, I have a very good article discussing null values in SQL Server, listed below:SQL Server Null Values ~ Into the Void (pun intended)