How to shrink MS SQL Server Database Log

by zebsadiq 2. February 2011 15:07

Recently I had to investigate why a certain virtual machine’s hard drive had filled up. I discovered that this was caused by a massive SharePoint database that I had imported. The log file for this database was nearly 30gb.

The way to check the log file sizes is by going to: C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\

Once you’ve determined which database’s log file needs to be shrunk, run the following bit of SQL replacing the database name with your own.

declare @dbname nvarchar(255) 
set @dbname = 'REPLACEWITHDATABASENAME' 
backup log @dbname with truncate_only DBCC SHRINKDATABASE (@dbname, 0)

After shrinking the log file, the size of the file went down to just 500kb.

Tags:

SQL Server 2005

Comments

2/27/2014 12:05:30 AM #

How to shrink SQL Server 2008 Database log

How to shrink SQL Server 2008 Database log

Zeb Sadiq | Reply

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading



Calendar

<<  April 2025  >>
MoTuWeThFrSaSu
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

View posts in large calendar