Shrink databasename_Log.LDF file on Microsoft SQL

Since I administer a very high load news site, I noticed that MSSQL log file of the site database is growing enormously. Database itself devided into 2 files one 330MB and the other 721MB, but log files grew to 5GB for the first file, and 20GB for the second file.

Since Microsoft doesn’t recommend that you delete these files, you need to shrink them to smaller files. To do this you have to backup your database (f.e. acctfiles) log files with truncate_only option.

Go to Start > Programs > Microsoft SQL Server > Query Analyzer, when it opens select your database in the drop-down field. Copy and paste the following code in your query window:

backup log acctfiles with truncate_only
DBCC SHRINKFILE (acctfiles_Log,1)

This will backup log files for database named acctfiles with truncate_only parameters and then it will perform shrinkfile command toacctfiles_Log files and shrink it down to 1MB.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.