?
Solved

Log file size in MS SQL 2005

Posted on 2008-11-13
5
Medium Priority
?
623 Views
Last Modified: 2012-05-05
Hi,

I have a MS sql server 2005 database that has a 105GB big logfile. Is there anyway to shrink and limit this logfile without loosing data? It's beginning to take up my whole disk.

Thanks for help!

Peter
0
Comment
Question by:peternordberg
  • 2
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
cluebeck earned 1500 total points
ID: 22948664
The behaviour of a database log file depends on the recovery mode of the database. Check the recovery mode on the properties -> options tab of the database in question.

In Full mode the log file only gets flushed once the log files are backed up. This ensures that you can restore your databse to any state in the past.

In Simple mode the log file only contains open transactions, so it is usally only a few MBs in since and doesn't grow.

Set the database to simple mode if you are happy with only being able to restore the database to full backups. Then select Tasks -> Shrink -> Files

If you want to keep running in full recovery mode, you have to backup using Tasks -> Backup using the Backup type "Logfiles". Afterwards you can Shrink the files.

In any case you will not loose data, since the log only keeps track of changes, the actuall up-to-date data is always stored in the database itself.
0
 
LVL 8

Expert Comment

by:OBonio
ID: 22948672
Obviously do a backup first then run this :

USE DatabaseName
GO
DBCC SHRINKFILE(<TransactionLogName>, 1)
BACKUP LOG <DatabaseName> WITH TRUNCATE_ONLY
DBCC SHRINKFILE(<TransactionLogName>, 1)

Open in new window

0
 

Author Comment

by:peternordberg
ID: 22948701
Hi and thanks for your answer. I followed you instructions and changed the mode to simple. Then I went to Task/Shrink/Files and executed that command, but the logfile seems to remain the same size. What can I have done wrong?
 
Peter
0
 
LVL 3

Expert Comment

by:cluebeck
ID: 22948754
When you do Task/Shrink/Files did you select Log-Files under Filetyp?
Also choose the second option where you set the file to shrink to a certain since. (simply type in 5 MB or so)
0
 

Author Closing Comment

by:peternordberg
ID: 31516313
Thanks for help!

Peter
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

831 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