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)
 Derived Column Expression Help

Author  Topic 

tooba
Posting Yak Master

224 Posts

Posted - 2014-08-25 : 12:21:53
Here is my Sample Data

ID,SID,FNAME
1,17,SMITH
2,6,JON
3,17,NOR

Here is my destination Columns and condition

ID,SID,SID2,FNAME

I want condion in derived column

IF SID = '17' then insert the value in SID
IF SID = '6' then insert the value in SID2

Here is the my final output looks like.

ID,SID,SID2,FNAME
1,17,,SMITH
2,,6,JON
3,17,,NOR

Any help?

Thank You

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-08-25 : 12:48:21
I did it with two DC column expressions:


Derived Column Name Derived Column Expression Data Type
SID Replace 'SID' SID == 17 ? 17 : NULL(DT_I4) DT_I4
SID2 <add as new column> SID == 6 ? SID : NULL(DT_I4) DT_I4

Go to Top of Page

tooba
Posting Yak Master

224 Posts

Posted - 2014-08-25 : 16:43:25
Awesome..... Thank You so much.
Go to Top of Page
   

- Advertisement -