Deleting 1 millions rows in SQL Server

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

    Here is something I have used:

    1. If the bad data is mixed in with the good-

      INSERT INTO #table 
         SELECT columns 
         FROM old_table 
         WHERE statement to exclude bad rows
      
      TRUNCATE old_table
      
      INSERT INTO old_table 
         SELECT columns FROM #table
      

提交回复
热议问题