?
Solved

Purge old records in database

Posted on 2011-09-29
3
Medium Priority
?
267 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
[X]
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
3 Comments
 
LVL 15

Assisted Solution

by:Eyal
Eyal earned 400 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 60

Assisted Solution

by:Kevin Cross
Kevin Cross earned 400 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 1200 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

Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

801 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