问题描述
我需要定期更新一个非常大的表,SqlBulkCopy的是完美的,只有我有一个2列的索引,prevents重复。有没有一种方法使用SqlBulkCopy的是插入或是否存在更新?
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 SQLBulkCopy as "insert or update if exists"?
如果没有,是什么这样做的最有效的方法是什么?同样,我说的是数以百万计的记录的表。
If not, what is the most efficient way of doing so? Again, I am talking about a table with millions of records.
感谢您
推荐答案
我想批量加载数据到临时临时表,然后做一个UPSERT进入决赛桌。请参阅http://www.databasejournal.com/features/mssql/article.php/3739131/UPSERT-Functionality-in-SQL-Server-2008.htm做一个更新插入的一个实例。
I would bulk load data into a temporary staging table, then do an upsert into the final table. See http://www.databasejournal.com/features/mssql/article.php/3739131/UPSERT-Functionality-in-SQL-Server-2008.htm for an example of doing an upsert.
这篇关于任何方式使用SqlBulkCopy"插入或更新是否存在"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!