PDF download Download Article PDF download Download Article

This wikiHow teaches you how to find out the size of a database’s transaction log, as well as how much of the total log space it’s using, on a Microsoft SQL Server.

Manage and Display Log File Size in SQL

To check the transaction log size in a SQL server, log into the SQL Server Management Studio and select the database. Open a new query, enter the transaction log code, and then click Execute.

  1. You can check the transaction log usage locally on the server or when connected remotely.
  2. It’s in the left panel.
    Advertisement
  3. It’s in the toolbar at the top of the window.
  4. To view the actual size of the log, as well as the maximum size it can take up in the database, type this query and then click Execute in the toolbar: [1]
      <USE nameofdatabase;  
      GO
      SELECT file_id, name, type_desc, physical_name, size, max_size  
      FROM sys.database_files ;  
      GO>
      
  5. To check how much log space is currently in use, type this query and then click Execute in the toolbar: [2]
      <USE nameofdatabase;  
      GO
      
      SELECT (total_log_size_in_bytes - used_log_space_in_bytes)*1.0/1024/1024 AS [free log space in MB]  
      FROM sys.dm_db_log_space_usage;>
      
  6. Advertisement

Expert Q&A

Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement

Tips

Submit a Tip
All tip submissions are carefully reviewed before being published
Name
Please provide your name and last initial
Thanks for submitting a tip for review!

You Might Also Like

Check the Query Performance in an SQL Server Check SQL Server Query Performance: Step-by-Step Guide
Find the Largest Files in Windows 10 Find Large Files on Windows 10 or 11: 3 Easy Ways
Create a SQL Server DatabaseCreating a Database With SQL Server Management Studio
Check Memory Usage Check Your Computer's Memory Usage: Complete Guide
Check an IIS Event Log on WindowsCheck an IIS Event Log on Windows
Find out the Size of a Hard DriveFind out the Size of a Hard Drive
Check Your Hard Disk Space Check Free Hard Disc Space on PCs, Macs, iPhones & Androids
Open an SQL FileView and Edit SQL Files: MySQL Workbench, Excel, & More
Linux How to Find Large Files Find the Largest Files on Your Linux System
Check Logs in Unix Check Logs in Unix Systems
Check Your Storage on Your AndroidCheck Your Storage on Your Android
Check the Remaining Memory on a USB Flash Drive3 Easy Ways to Check Storage Space on a Flash Drive
Check Error Logs in Putty View Error Logs in PuTTY: SSH & Linux Logging
Check the Event Log on PC or MacCheck the Event Log on PC or Mac
Advertisement

About This Article

Nicole Levine, MFA
Written by:
wikiHow Technology Writer
This article was co-authored by wikiHow staff writer, Nicole Levine, MFA. Nicole Levine is a Technology Writer and Editor for wikiHow. She has more than 20 years of experience creating technical documentation and leading support teams at major web hosting and software companies. Nicole also holds an MFA in Creative Writing from Portland State University and teaches composition, fiction-writing, and zine-making at various institutions. This article has been viewed 104,524 times.
How helpful is this?
Co-authors: 4
Updated: April 10, 2024
Views: 104,524
Thanks to all authors for creating a page that has been read 104,524 times.

Is this article up to date?

Advertisement