Click here to Skip to main content
Sign Up to vote bad
good
See more: SQLServer
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 14 Oct '12 - 5:36
lalitkr1.3K
Edited 14 Oct '12 - 5:44
Maciej Los56.1K

Comments
Wes Aday - 14 Oct '12 - 11:39
Okay so use IS NOT NULL to exclude nulls from your results.

2 solutions

Use the Concept of the following line
 
SET CONCAT_NULL_YIELDS_NULL OFF;
 
Select  query
 
SET CONCAT_NULL_YIELDS_NULL ON;
 

 

 

 
________________________________________________________________________________
  Permalink  
Have a look at these functions: COALESCE[^] and ISNULL[^]
  Permalink  
Comments
Sandeep Mewara - 14 Oct '12 - 14:12
My 5!
Maciej Los - 14 Oct '12 - 15:33
Thank you, Sandeep.

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 OriginalGriff 213
1 Sergey Alexandrovich Kryukov 159
2 Richard MacCutchan 150
3 Maciej Los 136
4 Tadit Dash 110
0 Sergey Alexandrovich Kryukov 10,264
1 OriginalGriff 7,937
2 CPallini 4,201
3 Rohan Leuva 3,522
4 Maciej Los 3,135


Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 19 Oct 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid