Wednesday, February 06, 2013

COALESCE and ISNULL and data type precedence

13 years of SQL Server, and you still learn something new. I always thought COALESCE and ISNULL where the same (for 2 arguments) and would return the data type of the first argument. It turns out this is not the case. What do you think happens when you run "SELECT COALESCE('', GETDATE())" Run it and find out. Running "SELECT ISNULL('', GETDATE())" gives a different answer, and what I would have expected for both. See also