Solved

Purge old records in database

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

733 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