At least one of the arguments to COALESCE must be a typed NULL
COALESCE T-SQL function returns the first non-null expression among its variable number of arguments.
And what happens if all arguments to the Coalesce are null values.
SELECT COALESCE(NULL, NULL)
The outcome of the coalesce function in this case will be :
Msg 4127, Level 16, State 1, Line 1
At least one of the arguments to COALESCE must be a typed NULL.
This is totally different from the ISNULL function outcome with NULL as the return value.
SELECT ISNULL(NULL, NULL)
All arguments should be typed NULL, you can check out the MSDN reference at MSDN T-SQL Coalesce Reference
So if you pass a NULL parameter as CAST(NULL as int) for example to COALESCE function as an argument, then the return value will be NULL.
SELECT COALESCE(NULL, NULL, CAST(NULL as int), NULL)
