You can use a Microsoft® ActiveX® script to code a transformation between one or more source and destination columns, or between a source or destination column and a global variable.
Because transformation scripts are executed for each row of data transformed, actions such as creating ADO connections, while useful in ActiveX script tasks, are not appropriate here. These are examples of ActiveX script transformation scripts.
This ActiveX transformation script, written in Microsoft JScript®, copies all the columns from the source-to-destination table, converting any text characters to upper case:
function main() {
for ( var i = 1; i <= DTSSource.Count ; i++ )
DTSDestination(i) = toUpperCase(DTSSource(i));
return(DTSTransformStat_OK);
}
This ActiveX transformation script, written in Microsoft Visual Basic® Scripting Edition, in the Employees table of the Northwind database:
function main()
DTSDestination("Employee ID") = DTSSource("Employee ID")
DTSDestination("Name") = UCASE(DTSSource("Last Name") +" " _
+ DTSSource("First Name")
DTSDestination("Title") = DTSSource("Title")
Main = DTSTransformStat_OK
end function
When importing data from a file to an OLE DB destination table, you may need to use the CDATE function to convert date data if the date format is in a text or character field and is not in the format required by OLE DB, which is yyyy-mm-dd hh:mm:ss:sss:
function main()
DTSDestination("Total Sales") = DTSSource("Total Sales ")
DTSDestination("DestColumnDate") = CDATE(DTSSource("SourceColumnDate"))
Main = DTSTransformStat_OK
end function