且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何同时更新和添加新记录

更新时间:2023-12-06 15:32:04

更好的方法之一是使用教程上,使用起来比其他一些命令要复杂一些.

One of the better ways to handle this is with the MERGE command in SQL. Mssqltips has a good tutorial on it, it can be a bit trickier to use than some of the other commands.

此外,由于锁定,您可能希望将其分解为多个较小的事务,除非您知道在更新过程中可以容忍阻塞.

Also, due to locking you may want to break this up into multiple smaller transactions, unless you know you can tolerate blocking during the update.