Click here to Skip to main content
11,645,889 members (77,627 online)
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 5:36am
lalitkr1.7K
Edited 14-Oct-12 5:44am
Maciej Los187.5K
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 OriginalGriff 628
1 jyo.net 514
2 Sergey Alexandrovich Kryukov 478
3 Afzaal Ahmad Zeeshan 378
4 DamithSL 260
0 OriginalGriff 1,143
1 jyo.net 994
2 Sergey Alexandrovich Kryukov 808
3 Afzaal Ahmad Zeeshan 702
4 DamithSL 691


Advertise | Privacy | Mobile
Web02 | 2.8.150731.1 | Last Updated 19 Oct 2012
Copyright © CodeProject, 1999-2015
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