Shrink MSSQL Database Transaction Logs

Have you ever encounter problem when managing MSSQL databases, the transactions logs is eating up your hard disk if you not initially configured to be limit in growth value. So, when you see this kind of problem, you actually can shrink the transaction log, and then change the limit of growth value using MSSQL Management Studio.

1. Open MSSQL Management Studio

2. Open the SQL command windows and put following lines

USE <DatabaseName>
GO
DBCC SHRINKFILE(<TransactionLogName>, 1)
BACKUP LOG <DatabaseName> WITH TRUNCATE_ONLY
DBCC SHRINKFILE(<TransactionLogName>, 1)
GO
									

Replace the <DatabaseName> and <TransactionLogName> with respective value and execute the SQL. Now your transaction logs will be shrinked and you will save a lot of disk space. Do not forget to do the prevention action afterwards!

2 thoughts on “Shrink MSSQL Database Transaction Logs

  1. When you reference “Do not forget to do the prevention action afterwards!” – are you referring to setting the growth limit on the transaction log?

    Reply

Leave a Reply

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