sql-server - 如何使用以下查询进行批量更新
问题描述
Merge DBO1..tblinventoryStock_Targer as T
Using DBO2..tblinventoryStock_Source as S
on S.Inventorycode =T.Inventorycode and
S.Locationcode =T.Locationcode
when matched then
update set T.QtyOnhand = S.QtyonHand,
T.Modifydate=S.Modifydate,
T.QtySold = S.QtySold
when not matched by Target then
insert ( --Fields)
values(--Values);
我必须将它从 DB2 插入到 sql server 中的 DB1 我有大约一百万条记录。如何快速进行更新和插入我需要 5 分钟通过 C# 使用存储过程执行查询
解决方案
当您执行可能会影响一百万行的 UPDATE 时,最好分批执行。一次尝试 50,000 行的批次。
推荐阅读
- r - 使用 write.table 获取数据框,而无需 R 中每一行的初始部分
- haskell - 如何在 Haskell 中实现产生 Maybe String 的 safeReadFile 函数
- python - TypeError:列表索引必须是整数或切片,而不是解析列表时的str
- javascript - vue中页面刷新后如何显示加载的数据?
- mysql - MYSQL在由另一列排序的列中选择特定数量的重复值
- r - 为河图创建边
- javascript - 为点击事件定义和调用函数而不是内联函数
- django - 尝试使用子查询计算时差时出错
- uwp - Windows 应用商店不允许使用 runFullTrust 提交应用程序
- python - 动态构建代码并在 .write() python 中使用