I have a SQL table with Case_id
as a primary key. I'm using Visual Studio SSIS to import flat files into the table and a Task Factory Upsert destination component to handle the insert/update part. The source file also has a column for the update dates.
If I have one record in the source file where the Case_id matches a Case_id
already in the destination table the upsert works fine. But if the source file contains multiple records with the same primary key and different update dates, the package fails with a primary key violation. I don't see any functionality that allows me to select only the record with the most recent update date.
Any ideas on how I can handle that primary key violation? I'm thinking I may need to ditch the Upsert component and use some sort of MERGE statement with a MAX update date. I'm using SQL Server 2019, Visual Studio 2019, and SentryOne Task factory.