dbTalk Databases Forums  

SSIS: Which component for condition based transforming?

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss SSIS: Which component for condition based transforming? in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
knezi
 
Posts: n/a

Default SSIS: Which component for condition based transforming? - 03-09-2006 , 03:46 AM






Got the following problem:

Source Data Column: FirstName; LastName; Salutation
Target Data Column: FirstName; LastName; Gender

The source-column <Salutation> always contains string "Mr." or "Mrs.".

In case of <Salutation> contains "Mr.", target-column <Gender> should be "1".
In case of <Salutation> contains "Mrs.", target-column <Gender> should be "2".

Which component does support this?

Thank you

Mario

Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default RE: SSIS: Which component for condition based transforming? - 03-09-2006 , 05:23 AM






You can use a Derived Column transform. Add a new column int the bottom pane,
named Genedr. Use an expression like the following to assign the value for
your new Gender column-

[Salutation] == "Mr" ? 1 : [Salutation] == "Mrs" ? 2 : 3

This copes with unknown values, other than Mr or Mrs, and assigns 3. If you
are absolutely sure you will only ever have the two values you could shorten
it to-

[Salutation] == "Mr" ? 1 : 2

The key here is the conditional operator-
«boolean_test» ? «true_result» : «false_result»

"knezi" wrote:

Quote:
Got the following problem:

Source Data Column: FirstName; LastName; Salutation
Target Data Column: FirstName; LastName; Gender

The source-column <Salutation> always contains string "Mr." or "Mrs.".

In case of <Salutation> contains "Mr.", target-column <Gender> should be "1".
In case of <Salutation> contains "Mrs.", target-column <Gender> should be "2".

Which component does support this?

Thank you

Mario

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.