Any way to SQLBulkCopy “insert or update if exists”?

后端 未结 6 2058
青春惊慌失措
青春惊慌失措 2020-11-28 09:10

I need to update a very large table periodically and SQLBulkCopy is perfect for that, only that I have a 2-columns index that prevents duplicates. Is there a way to use SQLB

6条回答
  •  醉梦人生
    2020-11-28 09:46

    Instead of create a new temporary table, which BTW consume more space and memory.

    I created a Trigger with INSTEAD OF INSERT and use inside MERGE statement.

    But don't forget add the parameter SqlBulkCopyOptions.FireTriggers in the SqlBulkCopy.

    This is my two cents.

提交回复
热议问题