You should definitely not just "swallow" the exception. You should be trying to find these duplicates and not insert them if needed.
On method could be checking where not exists on the key.
INSERT INTO TargetTable
SELECT
KeyID,
blah,
blerg,
FROM SourceTable AS S
WHERE NOT EXISTS (
SELECT 1
FROM TargetTable AS T
WHERE S.KeyID = T.KeyID
)
This method will allow you to only INSERT
new rows into the table. This method of course does not account for any matching you may need to do for an UPDATE
, however that's outside the scope of this question but should still be thought about. Most users could also use MERGE
I'll post an example of that when I get time.