Shrink your SQL Server Log Files (LDFs)

If you just want to shrink your log files, you can use the following code, but make sure to replace DBName with whatever your real database name is.

USE DBName
ALTER DATABASE DBName SET RECOVERY SIMPLE
DBCC SHRINKFILE( 'DBName_log',1000 )
ALTER DATABASE DBName SET RECOVERY FULL

If by chance your log file isn’t named DBName_log, you can find out what the actual name is by using this bit of code:

USE DBName
SELECT name
FROM sys.database_files
WHERE type_desc = 'LOG'
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s