I have a scenario where i need to synchronize two tables in SSIS
Table A is in DATABASE A and TABLE B is in DATABASE B. Both tables have same schema. I need to have a SSIS package that Synchronize TABLE A with TABLE B in Such a way That
1. It inserts all the records That Exist in Table A into Table B
AND
2. Update TABLE B if Same "Key" exsit in Both but Updated records in Table A
For Example Table A and B both Contains Key = 123 both Few Columns in Table A has been Updated.
I am thinking about using Merge Joins but that helps with only insertion of New records. How i can manage to implement UPDATE thing as well
Use a lookup transformation .Source will be
Table Aand Lookup will beTable B.Map the common columns in both the table and select those columns which you need for insertion.After lookup useOLEDB destinationand the map the columns coming from the lookup and insert it intoTable BSame logic as above .Use lookup and instead of
OLEDB DestinationuseOLEDB Commandand then write the update sql .In the column mapping map the columns coming out of the
lookupCheck out this article
Checking to see if a record exists and if so update else insert
Using Merge :
You can execute the Merge SQL in
Execute SQL TaskinControl FlowUpdate :
The Lookup transformation tries to perform an equi-join between values in the transformation input and values in the reference dataset.You can just need to have one Data Flow Task .
Diagram
When the target table data does not have a matching value in the source table then lookup will redirect the target rows to the oledb destination which inserts the Data into source table(
Lookup No Match Output)When the target table rows matches for the business key with the source table then matched rows will be sent to the
Oledb Commandand using the Update SQL ,the all the target rows from the lookup will be updated in the source table .This is just an overview .There is a problem with the above design as when the rows matches irrespective of any change in the columns the source table will be updated .So kindly refer the above article or try for search for SCD component in ssis