Solved

Purge old records in database

Posted on 2011-09-29
3
261 Views
Last Modified: 2012-05-12
Hi,

We have an old database server that is running out of drive space, we'd like to clean up some of the old data by running a delete statement. However, when the query is running, the transaction log growns rapidly and filled out the available drive space (70GB) and eventualy failed the had to roll back. Is there a work around for this situation?

Thank you.
0
Comment
Question by:lo_oscar
3 Comments
 
LVL 15

Assisted Solution

by:Eyal
Eyal earned 100 total points
ID: 36817915
I have some ideas that may help

1) run small changes and commit
2) change the database recovery mode to full
3) shrink files
0
 
LVL 59

Assisted Solution

by:Kevin Cross
Kevin Cross earned 100 total points
ID: 36817941
What percentage of the table are you trying to DELETE? If it is a significant percent, you may consider transferring the rows you want to keep to a temporary location. Keep in mind, you will need to account for dependencies/relationships with other data; however, all that aside, once you have the 'good' rows copied off, TRUNCATE TABLE {your table name}. Then you can INSERT the 'good' rows back.
0
 
LVL 3

Accepted Solution

by:
kinsey earned 300 total points
ID: 36817945
First backup the database if you can,
Set the Recovery Mode to simple to keep the log from growing too fast.
If you still run out of space Delete the data in smaller subsets
You can CHECKPOINT the database after each delete to truncate the log
re-set the recovery model if it was not simple to begin with.

I assume there is no extra drive available to mov the log file to.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
A quick step-by-step overview of installing and configuring Carbonite Server Backup.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now