Steps to truncating log files and shrinking your database:
1. Get the physical names of your database file (MDF) and log file (LDF):
Run the following system stored procedure:
use
exec sp_helpfile
Record the name of the file from the “filename” colunm, excluding the path and file extension (e.g. if filename contains “C:\sqldatabases\yourdatabase_data.mdf” you want to save the string “yourdatabase_data”)
2. Truncate the database and shrink the database
The following set of SQL will shrink your database and “truncate” the log file. File in the parmaters surrounded by <…>. Note that you’ll need the two filename values from step 1.
USE
GO
BACKUP LOG
GO
DBCC SHRINKFILE (
GO
DBCC SHRINKFILE (
GO
exec sp_helpfile
When complete, this script will output the same information as in step 1. Compare the new size with the old.