Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Purge old records in database

Posted on 2011-09-29
3
264 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
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.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

860 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