|
DataPump ActiveX Script Conversion Examples |
|
DTS |
SSIS |
|
Example 1 |
|
DTSDestination("ProductID") = DTSSource("ProductID") |
No need to convert because there is no transformation involved in this example. Just map ProductID <->
ProductID in the Destination Adapter. If you have simple pattern like this then just remove from the script and also make sure
you remove from Script Component Input Columns to improve performance. |
|
Example 2 |
If DTSSource("TransCode") = "ACT" Then
DTSDestination("TransDescription") = "Acct Trans"
Else
DTSDestination("TransDescription") = "UNKNOWN"
End If |
In this example TransDescription column is derived from value of TransCode. Pattern like this when you don't
have exact mapping of source column to target column or Target column value is derived based on one or more source column
values then the best way is use derived column. You can also use script component but give first preference to Derived Column
if possible because its faster compared to script component. Some times you have to use Script component because of complexity
of code. Derived column is good for simple expressions.
Using Derived Column
Step 1: Add Derived Column Component in the pipeline
Step 2: Add new column (e.g. MyTransDescription)
Step 3: Type expression as below
[TransCode]="ACT"
? "Acct Transaction" : "UNKNOWN"
Step 4: On the Destination Adapter Mappings screen map MyTransDescription to Target column TransDescription
Using Script Component
You can do same thing with Script component but it will be slower than Derived column so if possible give first preference to
Derived Column.
Step 1: Select Input column TransCode (ReadOnly)
Step 2: Add New Output Column "MyTransDescription" under Input Output Columns tab and specify data type and length of
the column.
Step 3: Type the following scriptIf Row."TransCode" = "ACT" Then
Row.MyTransDescription = "Acct Trans"
Else
Row.MyTransDescription = "UNKNOWN"
End If
Step 4: On the Destination Adapter Mappings screen map MyTransDescription to Target column TransDescription
|
|
Example 3 |
If DTSSource("Discontinued") = 0 Or _
DTSSource("Discontinued") Is Null Then
DTSDestination("UnitPrice") = DTSSource("UnitPrice")+50
Else
DTSDestination("UnitPrice") = Null
End If |
If Row.Discontinued = 0 Or _
Row.Discontinued_IsNull Then
Row.UnitPrice = Row.UnitPrice + 50
Else
Row.UnitPrice_IsNull = True
End If
|
|
Example 4 |
DTSDestination("ProductName") = UCase(DTSSource("ProductName")) |
Row.ProductName = UCase(Row.ProductName) |
|
Example 5 |
|
DTSDestination("RecordTimeStamp") = Now() |
In this example source table doesn't have
RecordLoadTimeStamp column and value for target field is generated at
run time. For pattern like this you have to either use "Derived Column" component or use Script Component.
Using Derived Column
If you use derived column to add or modify column in the pipeline then

Using Script Component
If you decide to use script component then you have to add new column in the Output Columns (See below).
 After
adding column in the output column collection edit the script as below.
Row.RecordTimeStamp = DateTime.Now()
|