I’m creating an SSIS package to incrementally load data from an Excel sheet (exported from an iSeries database) into an SQL table, the issue I’m hitting at the moment is determining which records to update and which to insert in the data flow, I’ve seen it done by doing a term lookup, so I setup a term lookup, and the issue I’ve encountered is that I need to match multiple columns to compare a unique row (in the below example I’d need to match the Parent, 2nd, and RoutingCode at the least), and the Term Lookup transform only allows for one column to be matched, now in theory I could Output successful matches to a 2nd lookup and a 3rd but that seems like a roundabout solution, and with a large number of input rows would likely degrade performace, so I’m looking for any suggestions from you more experienced DBAs.
Sample data:
Parent 2nd Itm# 3rd Itm# Routing Code UpdatedColumn
------- ----------- ----------- -------------- -------------
921221 TF2-14511 TF2-14511 PLANNING 1568
921221 TF2-14511 TF2-14511 COAT&CAP 14545
921221 TF2-14511 TF2-14511 S.S 0-OVERLAPS 45556
842568 TF2-14511 TF2-14511 PLANNING 4545
Load the data from Excel spreadsheet into a staging table on the SQL Server database. Then use a query or stored procedure (ideally a stored procedure) to compare the data between the staging table and the destination where you would like to insert or update the data. If you are using SQL Server 2008 or above, you could make use of
MERGEstatement that can compare the source and target tables toINSERTorUPDATEthe records.Inserting, Updating, and Deleting Data by Using MERGE
You could load the data from Excel to SQL Server staging table using
Data Flow Task. On the Control Flow, you can place anExecute SQL Taskafter the Data Flow task to invoke the stored procedure that will contain theMERGEstatement.