It has been quite a long time since I've used SSIS. I'm using SSIS 2012. I'd like to insert rows from one table into another table. But, I'd like to only insert rows from the source, into the destination, that don't exist in the destination, based on the primary key. For existing rows, I'd like to simply ignore the rows from the source. I know it's a simple matter to insert rows from one table to another, but what's the best (most efficient) way to check to see if a row from the source exists in the destination and ignore it if it does?
Asked
Active
Viewed 1.8k times
1 Answers
15
Between your source and destination component, add a Lookup Component.
Configure the Lookup to Redirect to No Match Output for unmatched rows.
In your lookup source, write a query like SELECT T.PK1, T.PK2 FROM dbo.MyTable T
where you only pull back the primary keys and then compare you input data to the target table's.
What comes out of the no match output will be rows that do not exists in the destination.
Sample screenshots for a 2008 problem
-
Thank you. I'll give it a try. It was the component I wasn't sure about, and which one to use. – Randy Minder Sep 25 '13 at 17:13