How to Shrink Your Database Transaction Log

How to Shrink Your Database Transaction Log

If you have noticed that your transaction log on your SQL Server database has grown incredibly large after a long transactional process, you can try this to shrink it back down:

 
DBCC SHRINKFILE(mydatabase_log, 2)
GO
 
BACKUP LOG mydatabase WITH TRUNCATE_ONLY
GO
 
DBCC SHRINKFILE(mydatabase_log, 2)
GO

Of course, you’ll want to replace “mydatabase” with the name of the database you wish to shrink and “mydatabase_log” with the name of the log for that database.

This entry was posted in MS SQL Server. Bookmark the permalink.

Leave a Reply

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