Solved

How do I properly remove then recreate a SQL Log file that has gotten too large

Posted on 2007-11-30
6
1,543 Views
Last Modified: 2008-02-01
LDF File for my SQL DB has approached the point of filling the disk it is on. What is the proper way to shrink it substantially OR remove the recreate it.

Best,
D Summers
0
Comment
Question by:dsummers801
6 Comments
 
LVL 31

Expert Comment

by:James Murrell
ID: 20381348
0
 
LVL 11

Expert Comment

by:Otana
ID: 20381356
If you want to remove and recreate it, right-click on the database in Enterprise Manager, All Tasks, detach database. Rename the LDF file, and the re-attach the database (right-click on databses, all tasks, attach database). You'll get a message saying LDF file can not be found, new one will be created. If attach worked, you can delete the old LDF file.
0
 
LVL 3

Expert Comment

by:Martin-Smith
ID: 20381375
The link above involves database downtime. To just clear the log you can set the database recovery model to simple then use the "shrink files" option. And reset the recovery model to full. This could completely mess up your backups though!
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 21

Expert Comment

by:Kevin3NF
ID: 20381885
Back it up.  Then use the GUI to shrink it.  Simplest solution with no downtime, no changes to the database.
0
 
LVL 6

Expert Comment

by:PaultheBroker
ID: 20382549
I had this problem on my server - the underlying cause is the recoveryoptions that you have set.  You probably have it set so that it increments the log until backup, whereby the log would get truncated automatically, but I'm guessing you are not backing up the database, so the log file is just getting larger and larger...one solution is to create a Maintenance Plan (right click the DB -> All Tasks... in Enterprise Manager to create a backup plan.

Alternatively, along the lines that Martin suggests, change the Recovery Model to SIMPLE to eliminate the transaction log altogether ... though only good for datbases you don't care too much about !! :)

BOL entry: "When a database is created, it has the same recovery model as the model database. To alter the default recovery model, use ALTER DATABASE to change the recovery model of the model database. You set the recovery model with the RECOVERY clause of the ALTER DATABASE statement"
0
 
LVL 6

Accepted Solution

by:
PaultheBroker earned 125 total points
ID: 20382777
So what I'm saying is that if you have a backup schedule, then the log file should automatically truncate itself, so you shouldn't need to worry about this, and if you don't have a backup schedule, then you probably don't need the log file anyway (if your system goes down, you are f***d anyway).

And I think just running a backup on the database should clear out the log file, so that is the only thing you need do....what am I missing guys???
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

757 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

19 Experts available now in Live!

Get 1:1 Help Now