Click here to Skip to main content
15,896,522 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Concat Function in SQL Server

When i add null with any data type either it is int , varchar , char , nvarchar , It re return the null values always , my query is that instead of null value i want the result excluding the null values for example

So i need a query which will return the result without null value

1st - Select Convert(nvarchar(20) , 1) + Null
Output = Null

My required result 1

2nd - Select 'A' + null
Null


My required result should be A instead of Null
Posted
Updated 14-Oct-12 5:44am
v2
Comments
[no name] 14-Oct-12 11:39am    
Okay so use IS NOT NULL to exclude nulls from your results.

Have a look at these functions: COALESCE[^] and ISNULL[^]
 
Share this answer
 
Comments
Sandeep Mewara 14-Oct-12 14:12pm    
My 5!
Maciej Los 14-Oct-12 15:33pm    
Thank you, Sandeep.
SQL
Use the Concept of the following line

SET CONCAT_NULL_YIELDS_NULL OFF;

Select  query

SET CONCAT_NULL_YIELDS_NULL ON;







________________________________________________________________________________
 
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