SQL Server, T-SQL, ASP.NET, Javascript, SAP, ABAP Programming

Kodyaz Development Resources

Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Vista, etc.
Welcome to Kodyaz Development Resources Sign in | Join | Help




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)





Related SQL Resources

SQL Server Articles

SQL Server Tools

SQL Blog

SQL Server 2008 Blog

Certification Exams Blog

Reporting Services Blog

Analysis Services Blog

MS SQL Server Forums














Copyright © 2004 - 2010 Eralper Yilmaz. All rights reserved.
Powered by Community Server, by Telligent Systems