Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends,

I would like to know that why select 'abc' + null results in null.

Thanks,
Jagjot
Posted

You can switch it off.

SET CONCAT_NULL_YIELDS_NULL { ON | OFF }

http://msdn.microsoft.com/en-us/library/ms176056.aspx[^]
 
Share this answer
 
Comments
Manas Bhardwaj 1-Feb-11 7:13am    
+5.
Rayalacheruvu Hemanth 24-Jul-19 13:51pm    
yeah, its working.
thanks lot.
"When you concatenate null values, either the concat null yields null setting of sp_dboption or SET CONCAT_NULL_YIELDS_NULL determines the behavior when one expression is NULL. With either concat null yields null or SET CONCAT_NULL_YIELDS_NULL enabled ON, 'string' + NULL returns NULL. If either concat null yields null or SET CONCAT_NULL_YIELDS_NULL is disabled, the result is 'string'."

This was from http://msdn.microsoft.com/en-us/library/aa276862(v=sql.80).aspx[^].
 
Share this answer
 
Comments
Manas Bhardwaj 1-Feb-11 7:12am    
I should increase my typing speed :)
+5
Abhinav S 1-Feb-11 7:18am    
You'll get the next answer.
:)
Manas Bhardwaj 1-Feb-11 7:22am    
:)
This is because CONCAT_NULL_YIELDS_NULL [^] is by default set as ON. YOu can turn it off in your query and the result will be affected.
Although, turning it off is not recommended and should be used carefully.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900