August 11, 2009 at 8:29 am
SQL 2005 I have a table with the following fields:
Segment1 (nvarchar(50), null)
Segment2 (nvarchar(50),null)
national_identifier(nvarchar(50), null)
The actual data contained in these fields is typically numbers. The national identifier contains social security number formatted (123-44-2298). I cannot, for anything, get these fields to concatenate. I need to create a field that concatenates all of the 3 fields above. I've tried CAST and CONVERT but no matter what I do the results show NULL.
Segment1 + Segment2 AS 'MyField' also results in NULL.
I've read every posting I can see in the forum but can't seem to resolve this.
August 11, 2009 at 8:47 am
lnelson (8/11/2009)
SQL 2005 I have a table with the following fields:Segment1 (nvarchar(50), null)
Segment2 (nvarchar(50),null)
national_identifier(nvarchar(50), null)
The actual data contained in these fields is typically numbers. The national identifier contains social security number formatted (123-44-2298). I cannot, for anything, get these fields to concatenate. I need to create a field that concatenates all of the 3 fields above. I've tried CAST and CONVERT but no matter what I do the results show NULL.
Segment1 + Segment2 AS 'MyField' also results in NULL.
I've read every posting I can see in the forum but can't seem to resolve this.
Sounds like you may have some null values. Try this:
select isnull(Segment1,'') + isnull(Segment2,'') as MyField from dbo.yourtable;
August 11, 2009 at 9:19 am
Thanks, that solved my problem. I actually have some internal data issues that were causing there to be NULL values when there should not be. Problem solved.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply