Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
SQL
My disk is running out of space and as a result I decided to free some space by deleting old data. I tried to delete 100,000 by 100,000 as there are 240 million records to be deleted. But I am unable to delete them at once and shrinking the database doesn't free much space. This is the error im getting at times.

The transaction log for database 'TEST_ARCHIVE' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases

How can I overcome this situation and delete all the old records? Please advice.
Posted

1 solution

The problem is that the DELETE query itself try to write into the log, but there is no disk space to enlarge the log...
You have 3 options:
1. TRUNCATE TABLE[^] the table...It will remove ALL the records without log...
2. If you need to keep part of the records, than create a temp table and insert the records-to-save into it, than run TRUNCATE TABLE and copy back the saved records...
3. Change the recovery mode of you DB to simple and than delete the rows. After that change recovery mode back...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900