Log file size in MS SQL 2005

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
Peter NordbergIT ManagerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cluebeckCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
OBonioCommented:
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
Peter NordbergIT ManagerAuthor Commented:
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
cluebeckCommented:
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
Peter NordbergIT ManagerAuthor Commented:
Thanks for help!

Peter
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.