How to Shrink Transaction Logs of Database in MS SQL?

This article will assist you to shrink/truncate the transaction logs of database in MS SQL Server.

  1. Connect to MS SQL Server through MS SQL Management Studio.

    MS SQL Server Management Studio

  2. In MS SQL Management Studio click on new query as shown below.

    New Query

  3. In query window, type the following command and execute it.

    Query Result

    USE testdb // Replace you database name with 'testdb'.
    DBCC SHRINKFILE (testdb_log, 1); // Replace your database log file name with 'testdb_log' and your desired target size with '1'.

    It will shrink the log file to 1 MB. Once you execute the command, you can see the execution results in Messages tab as shown in above screen capture.

Note:
 target_size is the size for the file in megabytes. If you do not specify this value, DBCC SHRINKFILE reduces the size to the default file size. The default size is the size specified when the file was created.


  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

How to configure MSSQL server default language configuration option?

Recently, we faced strange issue wherein one of our customers was capturing error messages coming...

How do I connect to MSSQL Server 2008 from SQL Server Management Studio?

This article will guide you on how to connect to MS SQL Server 2008 from SQL Server Management...

How to use MSSQL Activity Monitor to find the most expensive query?

A slow and long running SQL query execution consumes much processor, memory, and disk of your...

vs shell installation has failed with exit code 1638.

You may receive the following error while installing MSSQL 2017 on Windows 2012 R2 Server. vs...

How to take MSSQL database offline or bring it online?

Sometimes, you come across to a situations when you are required to physically move the database...