Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 SSIS and Import/Export (2012)
 SSIS Expression to Merge Two Columns

Author  Topic 

brubakerbr
Yak Posting Veteran

53 Posts

Posted - 2013-11-07 : 12:33:14


I have a .CSV import that I will be performing a series of Transformations on. The first Transformation that I need to do is to merge two City Columns into 1 column.

The data that I have looks like this.

| City1 | City2 |
|Wichita| |
| |Houston|
| |Chicago|
|Denver | |

The required output should be,

| City |
|Wichita|
|Houston|
|Chicago|
|Denver |

I want to keep this as an SSIS Derived Column Expression so that I can tie it to the rest of the transformation that I need to perform.

I already went back to the vendor and asked them to correct the data, they denied it. Now it's up to me to correct the dirty data so that we can use it in a series of reports.

Thank you in advance for any support.


Brian D. Brubaker
Business Intelligence Analyst
Viega LLC

brubakerbr
Yak Posting Veteran

53 Posts

Posted - 2013-11-07 : 13:09:53
expression that I used:
City2 == "" ? City1 : City2

City2 becomes the column that I use.

Brian D. Brubaker
Business Intelligence Analyst
Viega LLC
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-07 : 13:16:08
Are you sure that they both wont have data in any case? what if both City1 and City2 have different data?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

brubakerbr
Yak Posting Veteran

53 Posts

Posted - 2013-11-08 : 11:24:39
I checked the data.

I ran into that with City1, it had Suite Numbers in it and I didn't want that. Plus, it wouldn't pull the data from City2 if the Suite Numbers were there. But i noticed that City 2 was always populated with a city name. So I just flipped it and pulled the City name from City1 into City 2 and used City2 as my clean column.

I have a years worth of data that I compared and it was all the same. City2 was the column to us and if City 2 was blank, I pulled the name fromCity1 over to give me a complete column.



Brian D. Brubaker
Business Intelligence Analyst
Viega LLC
Go to Top of Page
   

- Advertisement -