Data Driven Query Update Row Problem
I am trying to compare two tables and update or insert the destination table based on a value in the source table. Below is the script I've setup in a data driven query task:
Function Main()
DTSDestination("Comments") = DTSSource("Comment")
DTSDestination("Zip") = DTSSource("Zip")
DTSDestination("State") = DTSSource("State")
DTSDestination("City") = DTSSource("City")
DTSDestination("Address2") = DTSSource("Address2")
DTSDestination("Address") = DTSSource("Address1")
DTSDestination("PayorName") = DTSSource("Description")
DTSDestination("PayorID") = DTSSource("ID")
Select Case DTSSource("UpdateKey")
Case "I"
Main = DTSTransformstat_InsertQuery
Case "U"
Main = DTSTransformstat_UpdateQuery
Case Else
Main = DTSTransformstat_SkipRow
End Select
End Function
PayorID and ID are the two respective primary keys.
The "I" or insert case works fine. However, if there is a "U" or Update row anywhere in the table, the script performs a Column Copy and every row is populate with the data of the last row with a "U" in the UpdateField.
What am I doing wrong?
|