How to shrink transaction log file for a database?

The following article gives some background on how to stop the transaction log from growing

Using the steps below one can shrink the transaction log.

Use TestDB
SELECT file_id, name FROM sys.database_files
GO

file_id name
1 TestDB
2 TestDB_log

DBCC SHRINKFILE (‘TestDB_log’, 2)
GO
BACKUP LOG TestDB WITH TRUNCATE_ONLY
GO
DBCC SHRINKFILE (‘TestDB_log’, 2)
GO

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 )

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.