In SQL Server, You need to delete some data in a large data table Table1 (more than 10 million records). If you use the delete method, the execution usually times out. You can use the following method:
Select the record you want to keep to the new table.
Select * into Table2 From Table1 Where Time> = '2017-03-10'
Then directly Truncate Table1. No log is recorded in whatever recovery mode: Truncate table Table1
Finally, rename Table2 to Table1: EC sp_rename 'table2' and 'table1'
Note:
The select * into statement does not have this function, but simply generates tables, excluding primary keys and default values. To be the same as the source Table, you can generate the Create Table script for the source Table, modify the Table name, key name, and constraint name, and Create table2 first ,, USE insert into table2 select * from table1 to copy the data.