Earlier I wrote a blog post SQL SERVER – A Quick Note on CONCAT_NULL_YIELDS_NULL and in follow up to the blog post, I received few questions. Let me try to answer those questions in following blog post. One question was how to check the database level IsNullConcat setting.

Q: How do we know if setting which returns NULL when concated to another NULL value is ON at database level?
A: You can run following script to identify the settings of the database level. In my script I have described AdventureWorks database and is checking if the settings which returns NULL when any other value is concated with NULL or not. If the query returns 1 that means when any value is concated with NULL it will return NULL. If the query returns 0 it means when any value is concated with NULL, it will still return original value and impact of NULL will be ignored.
-- Check Database Level settings SELECT DATABASEPROPERTYEX('AdventureWorks2012', 'IsNullConcat');
Q: How do we know if setting which returns NULL when concated to another NULL value is ON at session level?
A: You can run following script to identify the settings of the session level. If the query returns 1 that means when any value is concated with NULL it will return NULL. If the query returns 0 it means when any value is concated with NULL, it will still return original value and impact of NULL will be ignored.
-- Check Session Level settings SELECT SESSIONPROPERTY('CONCAT_NULL_YIELDS_NULL');
Additionally, you can read comment of Manigandan as he has demonstrated that we can also get the impact of function ISNULL with using another function COALESCE.
Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.
Discover more from SQL Authority with Pinal Dave
Subscribe to get the latest posts sent to your email.




