How to Shrink Database Transaction Log

Created by Cheng Kah Poh, Modified on Fri, 25 Sep, 2020 at 11:45 AM by Cheng Kah Poh

  1. Connect to Database use Microsoft SQL Server Management Studio
  2. Start a New Query
  3. Copy and Paste the following SQL Script into the New Query
  4. DECLARE @dbName VARCHAR(50) DECLARE @logName VARCHAR(100) SELECT @dbName = DB_NAME() SELECT @logName = name FROM SYS.database_files WHERE type = 1 EXECUTE('ALTER DATABASE[' + @dbName + '] SET RECOVERY SIMPLE') DBCC SHRINKFILE (@logName, 1); EXECUTE('ALTER DATABASE[' + @dbName + '] SET RECOVERY FULL') 




  5. Execute the Query


Please refer How to Connect to Database use Microsoft SQL Server Management Studio

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article