Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Purge old records in database

Posted on 2011-09-29
3
Medium Priority
?
270 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

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. …
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
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.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

597 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