Click here to Skip to main content
12,952,792 members (36,385 online)
Rate this:
 
Please Sign up or sign in to vote.
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 14-Oct-12 5:36am
lalitkr1.8K
Updated 14-Oct-12 5:44am
Maciej Los253.1K
v2
Comments
Wes Aday 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 14-Oct-12 14:12pm
   
My 5!
Maciej Los 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
Top Experts
Last 24hrsThis month
OriginalGriff 6,389
CHill60 3,490
Maciej Los 3,103
Jochen Arndt 1,975
ppolymorphe 1,920


Advertise | Privacy | Mobile
Web01 | 2.8.170525.1 | Last Updated 19 Oct 2012
Copyright © CodeProject, 1999-2017
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