How to efficiently delete rows while NOT using Truncate Table in a 500,000+ rows table

后端 未结 8 1437
死守一世寂寞
死守一世寂寞 2020-11-30 01:30

Let\'s say we have table Sales with 30 columns and 500,000 rows. I would like to delete 400,000 in the table (those where \"toDelete=\'1\'\").

8条回答
  •  感情败类
    2020-11-30 01:41

    One way I have had to do this in the past is to have a stored procedure or script that deletes n records. Repeat until done.

    DELETE TOP 1000 FROM Sales WHERE toDelete='1'
    

提交回复
热议问题