August 26, 2010

Conditional Statement in Derive Column

Derive Column is another very useful Data Flow Transformation. We normally use it to derive one or more columns as it name described, by calculate some values or using other columns. Here, I'm going to explain how to do conditional statement in Derive Column.

First I drag and drop a Data Flow Task into the designer. within  this Data Flow Task I add Excel Data Source, Derive Column and Flat File Destination.


This is my Excel Source.



My Excel File contains few customer details.


I want to get this data into a Flat File with another column contains if the customer, Adult(Age > 20) or Youngster(Age<20).So I can write,

if(Age>=20)? "Adult" : "Youngster" ;

But this not works in Derive Column, we have to write,


(Age>=20)? "Adult" : "Youngster"



 Then we can arrange Flat File Destination.



Then we can run the package and see the result.


Here is the Flat File with data we want. You can see the extra column we made. I named it More Details.

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails