11
2007
There are a lot of articles to be found on this subject but here is a condensed procedure:
Your SQL transaction log is too big and you need to shrink it before SQL server explodes through lack of disk space:
- Back up your database – optional but a good idea as you are about to invalidate your transaction log backup history
- Open SQL Query analyser or goto new query in SQL Server Management Studio and run the following SQL code
- DBCC SHRINKFILE(myLogFileName, 100)
- BACKUP LOG myDatabaseName WITH TRUNCATE_ONLY
- DBCC SHRINKFILE(myLogFileName, 100)
- That’s it.
Notes:
Look in the Message tab as well as the results grid for output from these commands if it doesn’t work as expected.
DBCC SHRINKFILE logfile name is the logical name of the log file, usually databaseName_log but you can check by running ’sp_helpdb databaseName’ and looking at the name field in the file results grid. The final size is in 100Mb in the above example.
DBCC SHRINKFILE cannot shrink the log below its initial size – specified upon creation of the database.
DBCC SHRINKFILE can only truncate the log back to the last open transaction, changing into single user mode and or restarting SQL server may help here, just be sure the database is not in active use and see point 1 above.
You must be logged in to post a comment.
