Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL Server
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 6:36am
lalitkr1.5K
Edited 14-Oct-12 6:44am
v2
Comments
Wes Aday at 14-Oct-12 11:39am
   
Okay so use IS NOT NULL to exclude nulls from your results.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Have a look at these functions: COALESCE[^] and ISNULL[^]
  Permalink  
Comments
Sandeep Mewara at 14-Oct-12 14:12pm
   
My 5!
Maciej Los at 14-Oct-12 15:33pm
   
Thank you, Sandeep.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

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

 

 

 
________________________________________________________________________________
  Permalink  

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

  Print Answers RSS
0 George Jonsson 175
1 Kornfeld Eliyahu Peter 169
2 Zoltán Zörgő 139
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 19 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100