Shrink Database Transaction Logs in SQL Server to a Specified Target Size

Use this article to shrink transaction logs in the Synergize Deployment SQL Server database to a specified target size to free up or release unused hard disk space.

  1. To minimize performance impacts on users, we recommend performing this procedure during non-peak business hours. Consult with your DBA or database team before proceeding.

  2. Back up the database and transaction logs.

  3. Log in to Microsoft SQL Server Management Studio with SYSADMIN privileges.

  4. Run the following query:

    Use SHIPDOCS

    GO

    ALTER DATABASE SHIPDOCS SET RECOVERY SIMPLE WITH NO_WAIT

    DBCC SHRINKFILE(SHIPDOCS_Log, 6)

    ALTER DATABASE SHIPDOCS SET RECOVERY FULL WITH NO_WAIT

    GO

    This example shrinks the log file in the SHIPDOCS database to 6 MB. To allow the DBCC SHRINKFILE command to shrink the file, the file is first truncated by setting the database recovery model to SIMPLE.