Skip to content

Latest commit

 

History

History
70 lines (54 loc) · 3.13 KB

File metadata and controls

70 lines (54 loc) · 3.13 KB
title sys.dm_db_log_space_usage (Transact-SQL) | Microsoft Docs
ms.custom
ms.date 06/29/2017
ms.prod sql-non-specified
ms.reviewer
ms.suite
ms.technology
database-engine
ms.tgt_pltfrm
ms.topic article
f1_keywords
sys.dm_db_log_space_usage
sys.dm_db_log_space_usage_TSQL
dm_db_log_space_usage
dm_db_log_space_usage_TSQL
dev_langs
TSQL
helpviewer_keywords
sys.dm_db_log_space_usage dynamic management view
ms.assetid f6b40060-c17d-472f-b0a3-3b350275d487
caps.latest.revision 4
author BYHAM
ms.author rickbyh
manager jhubbard

sys.dm_db_log_space_usage (Transact-SQL)

[!INCLUDEtsql-appliesto-ss2012-asdb-xxxx-xxx_md]

Returns space usage information for the database log. (All log files are combined.)

Column name Data type Description
database_id smallint Database ID.
total_log_size_in_bytes bigint The size of the log
used_log_space_in_bytes bigint The occupied size of the log
used_log_space_in_percent real The occupied size of the log as a percent of the total log size
log_space_in_bytes_since_last_backup bigint The amount of space used since the last log backup
Applies to: [!INCLUDEsssql14-md] through [!INCLUDEsscurrent-md], [!INCLUDEssSDS].

Permissions

On [!INCLUDEssNoVersion] requires VIEW SERVER STATE permission on the server.

On [!INCLUDEssSDS] Premium Tiers requires the VIEW DATABASE STATE permission in the database. On [!INCLUDEssSDS] Standard and Basic Tiers requires the [!INCLUDEssSDS] admin account.

Examples

A. Determine the Amount of Free Log Space in tempdb

The following query returns the total free log space in megabytes (MB) available in tempdb.

USE tempdb;  
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;  

See Also

Dynamic Management Views and Functions (Transact-SQL)
Database Related Dynamic Management Views (Transact-SQL)
sys.dm_db_file_space_usage
sys.dm_db_task_space_usage (Transact-SQL)
sys.dm_db_session_space_usage (Transact-SQL)