任何方式使用SqlBulkCopy"插入或更新是否存在"? [英] Any way to SQLBulkCopy "insert or update if exists"?

查看:346
本文介绍了任何方式使用SqlBulkCopy"插入或更新是否存在"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要定期更新一个非常大的表,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进入决赛桌。请参阅<一href="http://www.databasejournal.com/features/mssql/article.php/3739131/UPSERT-Functionality-in-SQL-Server-2008.htm">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&QUOT;插入或更新是否存在&QUOT;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆