Truncate and shrink log files in SQL Server (2024)

This article describes the difference between shrinking and truncating the transaction log in Microsoft® SQL Server®. It outlines the different use scenarios and walks you through how to perform these tasks.

If a database is a simple recovery model, the system truncates the transaction log automatically after every transaction. For databases with a full or bulk-logged recovery model, the system truncates the transaction log only after a successful transaction log backup.

A full database backup does not truncate the log. If you don't take regular transaction log backups, the log file continues to grow until it runs out of space. While truncating the log makes the space available for use again, it does not decrease the transaction log file size. To reduce the size of the transaction log file, you need to shrink the log file.

Truncate the transaction log

Use the following steps to truncate the transaction log file in SQL Server Management Studio (SQL Server 2008 and later). Keep in mind that following these steps might result in data loss. You should not need to manually truncate the log because regular log backups should automatically perform this task.

Note: You need the sysadmin fixed server role or the db_owner fixed database role to truncate the log.

  1. Right-click the database and select Properties -> Options.

  2. Set the recovery model to Simple and exit the menu.

  3. Right-click the database again and select Tasks -> Shrink -> Files.

  4. Change the type to Log.

  5. Under Shrink action, select Reorganize pages before releasing unused space and click OK.

  6. When the process completes, switch the recovery model back to Full or Bulk-Logged and take a full database backup.

Understand shrinking the log

If you need to recover disk space from the transaction log file, consider shrinking the log file. Shrinking recovers space by moving data from the end of the file to unoccupied space at the front of the file. After the process creates enough space at the end of the file, it can be deallocated and returned to the file system. Shrinking logs helps after you perform an action that creates a large number of logs. You can only shrink the log if there is free space on the log file.

Shrink the transaction log

Use the following steps to truncate the transaction log file:

Note: You need the sysadmin fixed server role or the db_owner fixed database role to shrink the log.

  1. Right-click the database and select Tasks -> Shrink -> Files.

  2. Change the type to Log.

  3. Under Shrink action, select Release unused space and click OK.

Related Articles:

SQL Server database recovery models

Updated 9 months ago

Truncate and shrink log files in SQL Server (2024)
Top Articles
Where to Spot a Celebrity in Los Angeles
2022 Top FHA Lenders - Scotsman Guide
Sef2 Lewis Structure
Firestone Jbab
What Are The Hours Of Chase Bank Today
Comment créer et interpréter un tracé Q-Q dans R - Statorials
Super 8 Protho Junction
Meshuggah Bleed Tab
Safemark Grocery Exam Answers
B-hyve XR Smart Indoor/Outdoor Sprinkler Timer
Laanacooper
Atmosphere 16.0.1
Black Men Have Issues
7 Movierulz
Shell Shockers Online Unblocked
N-Vu Login
Porch Swing Plans Free Shopsmith
Home Depot Shopping On Line
Part City Near Me
Mendoza Clinic Pharmacy
18 Cafes in Yoyogi that You'll Want to Visit Repeatedly
1980 Monte Carlo For Sale Craigslist
Bad Moms 123Movies
Primerica Register
Autozone Cercano
Spirit Airlines Flightaware
Boulangerie Suffren 55
Understanding the Brand Architecture of Proctor & Gamble (P&G)
Loopnet Properties For Sale
Bowfa Ge
5Gomovies
Synonym For Saint Word Craze
Craigslist Hunting Land For Lease In Ga
Eras Tour Photographer Brings Exhibition to Miami
Weekly Math Review Q4 4 Answer Key | airSlate SignNow
Sofi Stadium Section 512
Froedtert Billing Phone Number
Www Craigslist Com Corpus Christi
149 Capstone Project Ideas & Examples – 2024
Samsung Tu7000 Vs Q60B
Joanna Fabric Near Me
Why Is 365 Market Troy Mi On My Bank Statement
Florida surgeon general favorably recommended after Democrats walk out of confirmation hearing | CNN Politics
Ups Location Near Me Drop Off
9294726233
Updated contract info for new secondary coach John Butler, rest of NU staff
Wral Nighttime Lottery
Shane Gillis Girlfriend: All About His Dating History, Career & More |Pudelek
Nuefliks.com
West Coast Budmail
Lovein Funeral Obits
Latest Posts
Article information

Author: Nathanael Baumbach

Last Updated:

Views: 6545

Rating: 4.4 / 5 (75 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Nathanael Baumbach

Birthday: 1998-12-02

Address: Apt. 829 751 Glover View, West Orlando, IN 22436

Phone: +901025288581

Job: Internal IT Coordinator

Hobby: Gunsmithing, Motor sports, Flying, Skiing, Hooping, Lego building, Ice skating

Introduction: My name is Nathanael Baumbach, I am a fantastic, nice, victorious, brave, healthy, cute, glorious person who loves writing and wants to share my knowledge and understanding with you.