SQL Batched Delete

后端 未结 9 1912
星月不相逢
星月不相逢 2021-02-20 04:29

I have a table in SQL Server 2005 which has approx 4 billion rows in it. I need to delete approximately 2 billion of these rows. If I try and do it in a single transaction, th

9条回答
  •  天命终不由人
    2021-02-20 05:03

    What distinguishes the rows you want to delete from those you want to keep? Will this work for you:

    while exists (select 1 from your_table where )
    delete top(10000) from your_table
    where 
    

提交回复
热议问题