How to Bulk Update with SQL Server?

一曲冷凌霜 提交于 2019-12-04 12:04:02

First of all there is no such thing as BULK UPDATE, a few things that you can do are as follow:

  1. If possible put your database in simple recovery mode before doing this operation.
  2. Drop indexes before doing update and create them again once update is completed.
  3. do updates in smaller batches , something like

    WHILE (1=1)
     BEGIN
       -- update 10,000 rows at a time 
       UPDATE TOP (10000) O
       FROM Table O inner join ... bla bla
    
        IF (@@ROWCOUNT = 0)
               BREAK;
    END
    

Note

if you go with the simple mode option, dont forget to take a full-backup after you switch the recovery mode back to full. Since simply switching it back to full recovery mode will not strat logging until you take a full backup.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!