Deleting 1 millions rows in SQL Server

后端 未结 7 2073
粉色の甜心
粉色の甜心 2020-12-04 08:46

I am working on a client\'s database and there is about 1 million rows that need to be deleted due to a bug in the software. Is there an efficient way to delete them besides

7条回答
  •  忘掉有多难
    2020-12-04 09:34

    Maybe this solution from Uri Dimant

    WHILE 1 = 1
    BEGIN
       DELETE TOP(2000)
       FROM Foo
       WHERE ;
       IF @@ROWCOUNT < 2000 BREAK;
    END
    

    (Link: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/b5225ca7-f16a-4b80-b64f-3576c6aa4d1f/how-to-quickly-delete-millions-of-rows?forum=transactsql)

提交回复
热议问题