SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to avoid technically the null values while concatenating columns


How to avoid technically the null values while concatenating columns

Author
Message
sgmunson
sgmunson
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17600 Visits: 4642
The problem usually shows up when you are trying to export to a text file, and the presence of any one NULL value throws the entire output record into NULL status, and depending on exactly how poorly the process was designed, it could be a problem such as missing records in the output file, or data showing up in the wrong location within the output data record because they account for everything except the empty string. The original poster has yet to come back with feedback beyond the apparent need to deal with 4 to 6 independent fields. Why that makes a difference is thus still unknown.

Hey manibad - do you have a solution now, or do you need more assistance? Let us know...

Phil Parkin (5/6/2013)
OK, I see what you are getting at, thanks. I still cannot see why that causes a formatting problem when outputting though.


Steve
‌(aka sgmunson)
Smile Smile Smile
Health & Nutrition
manibad
manibad
SSC Veteran
SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)SSC Veteran (269 reputation)

Group: General Forum Members
Points: 269 Visits: 143
sgmunson (5/6/2013)
I'm at the point of making an assumption about what the poster meant by their most recent post. Given the technique of concatenating a series of ISNULL functions whose parameters are all strings or casted or converted into strings, it's not that difficult to eliminate a null value from causing a problem in concatenation, and you just encapsulate the entire concatenation of ISNULLs within a NULLIF and you can preserve a NULL value for the case when all the fields are NULL as opposed to just one or more but not all. The assumption I make is that when they mention the idea of having 4 to 6 fields to deal with, that they mean that they need to concatenate more than just two fields. Whether that assumption holds true or not is something the poster would have to resolve for us by posting again. Does that explain?

Phil Parkin (5/6/2013)
sgmunson (5/6/2013)
The number of fields that can be included in the query's use of ISNULL and NULLIF is not limited to two. You can just keep concatenating an ISNULL function, and then NULLIF the entire concatenation, and thus have as many fields as you need. They just all need to be strings, or alternately, CAST-ed or CONVERT-ed to strings.


Steve - you sound like you understand the problem - can you explain it, because I still cannot comprehend properly what the issue is? :-)


"The assumption I make is that when they mention the idea of having 4 to 6 fields to deal with, that they mean that they need to concatenate more than just two fields. "the assumption what you has is perfect.i have the same situation to be dealt.Moreover i am rookie to SSIS and so i just came to know about the NULLIF function..and i will work on it...to fix my issues.
Phil Parkin
Phil Parkin
SSC Guru
SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)

Group: General Forum Members
Points: 52615 Visits: 21193
manibad (5/6/2013)
sgmunson (5/6/2013)
I'm at the point of making an assumption about what the poster meant by their most recent post. Given the technique of concatenating a series of ISNULL functions whose parameters are all strings or casted or converted into strings, it's not that difficult to eliminate a null value from causing a problem in concatenation, and you just encapsulate the entire concatenation of ISNULLs within a NULLIF and you can preserve a NULL value for the case when all the fields are NULL as opposed to just one or more but not all. The assumption I make is that when they mention the idea of having 4 to 6 fields to deal with, that they mean that they need to concatenate more than just two fields. Whether that assumption holds true or not is something the poster would have to resolve for us by posting again. Does that explain?

Phil Parkin (5/6/2013)
sgmunson (5/6/2013)
The number of fields that can be included in the query's use of ISNULL and NULLIF is not limited to two. You can just keep concatenating an ISNULL function, and then NULLIF the entire concatenation, and thus have as many fields as you need. They just all need to be strings, or alternately, CAST-ed or CONVERT-ed to strings.


Steve - you sound like you understand the problem - can you explain it, because I still cannot comprehend properly what the issue is? :-)


"The assumption I make is that when they mention the idea of having 4 to 6 fields to deal with, that they mean that they need to concatenate more than just two fields. "the assumption what you has is perfect.i have the same situation to be dealt.Moreover i am rookie to SSIS and so i just came to know about the NULLIF function..and i will work on it...to fix my issues.


I now know why I was confused - this problem has nothing to do with SSIS, it's merely a source/selection problem.


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search