Can you control concatenation of string values with null values? How ?

 Posted by Bhakti on 11/24/2009 | Category: Sql Server Interview questions | Views: 3948
Answer:

We can control this by setting CONCAT_NULL_YIELDS_NULL on or off.
When it is set to ON, the concatenation will result null and when it is set to OFF, it will result the string.
Setting it ON,
SET CONCAT_NULL_YIELDS_NULL on;

print 'testing' + NULL; --results NULL and prints nothing


Setting it OFF,

SET CONCAT_NULL_YIELDS_NULL off;

print 'testing' + NULL; -- results testing and prints the same


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response