Log file size in MS SQL 2005

Posted on 2008-11-13
Last Modified: 2012-05-05

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!

Question by:peternordberg
    LVL 3

    Accepted Solution

    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.
    LVL 8

    Expert Comment

    Obviously do a backup first then run this :

    USE DatabaseName
    DBCC SHRINKFILE(<TransactionLogName>, 1)
    DBCC SHRINKFILE(<TransactionLogName>, 1)

    Open in new window


    Author Comment

    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?
    LVL 3

    Expert Comment

    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)

    Author Closing Comment

    Thanks for help!


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    Title # Comments Views Activity
    store procedure with 6 parameters - OR 6 47
    combine data in sql 1 23
    get all customers 2 31
    report c# 9 56
    This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
    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 …
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    760 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

    8 Experts available now in Live!

    Get 1:1 Help Now