Deleting 1 millions rows in SQL Server

后端 未结 7 2045
粉色の甜心
粉色の甜心 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:47

    If you cannot afford to get the database out of production while repairing, do it in small batches. See also: How to efficiently delete rows while NOT using Truncate Table in a 500,000+ rows table

    If you are in a hurry and need the fastest way possible:

    • take the database out of production
    • drop all non-clustered indexes and triggers
    • delete the records (or if the majority of records is bad, copy+drop+rename the table)
    • (if applicable) fix the inconsistencies caused by the fact that you dropped triggers
    • re-create the indexes and triggers
    • bring the database back in production
    0 讨论(0)
提交回复
热议问题