Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
miranwar
Posting Yak Master
125 Posts |
Posted - 2007-03-02 : 06:29:40
|
HI,I need to delete 10 Million records from a table that were imported into our SQL server database by accident. We have run out of disk space and need to do a delete urgently. I have written this delete statement:set rowcount 5000/* 1) Delete first 10,000 Where Event ID is NULL on the Sign_Ons Table */delete from sign_ons where K_EVENT_ID is NULL/*If delete takes place than loop each time deleting 5000 recs, loop until there's no record left to delete*/while @@rowcount > 0begindelete from sign_ons where K_EVENT_ID is NULLendThe problem is know the transaction log will grow and we have no space while we do the delete. Should I force a checkpoint with the checkpoint command after each delete in the loop. Or will this slow it down. the table in question is critical to our websites and is constantly being accessed? The recovery Model is simple.The table is currently 10 Gig In Size: The resrved Space by Sp_SpaceUSed is showing 10 Gig. So I'm assuming the transaction log will approx grow by that amountCan someone please advise ASAPMany thanks |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-02 : 07:14:46
|
Try changing recovery mode to bolk_logged or simple first.Peter LarssonHelsingborg, Sweden |
 |
|
miranwar
Posting Yak Master
125 Posts |
Posted - 2007-03-02 : 07:45:12
|
Model is already Simple. Just need to prevent the log file physically growing as there is no room on the server. |
 |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2007-03-02 : 08:24:04
|
If you don't need any of the data in the table, truncate the table or drop the table.CODO ERGO SUM |
 |
|
|
|
|