SQL Server – Get Transaction Log Size and Log Space Used

Use the following T-SQL script to get the transaction log size and log space used of your database.

 

 

SELECT​​ DB_NAME(database_id)​​ AS​​ DatabaseName​​ ,

CAST((​​ total_log_size_in_bytes​​ /​​ 1048576.0​​ )​​ AS​​ DECIMAL(10,​​ 1))

AS​​ TotalLogSizeMB​​ ,

CAST((​​ used_log_space_in_bytes​​ /​​ 1048576.0​​ )​​ AS​​ DECIMAL(10,​​ 1))

AS​​ LogSpaceUsedMB​​ ,

CAST(used_log_space_in_percent​​ AS​​ DECIMAL(10,​​ 1))​​ AS​​ LogSpaceUsedPercent

FROM​​ sys.dm_db_log_space_usage;

 

 

Knowledge worth sharing...Share on linkedin
Linkedin
Share on facebook
Facebook
Share on google
Google
Share on twitter
Twitter