I am using SqlBulkCopy to insert batches of records to a server. If one record fails because of a unique constraint, I don't want to rollback the whole batch, but I want to do an update of the existing record instead.
I was hoping I could log the failing records key values then once the bulk insert is finished, go back and address them individually.
However I can't see any way of telling SqlBulkCopy to not to rollback the transaction on failure, nor how to get info on the failing record.
I could check the record exists before adding it to the SqlBulkCopy DataTable, but that would add considerable overhead.
I have checked the answers here which indicate using a staging table and some other sproc to do the insert/update after the bulk insert, but I think that sproc would need to process each record individually to either insert new or update the existing records - very time-consuming.
Any other tips or has nothing changed in the last 4 years?