| 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 |
|
||||
| ms.tgt_pltfrm | |||||
| ms.topic | article | ||||
| f1_keywords |
|
||||
| dev_langs |
|
||||
| helpviewer_keywords |
|
||||
| ms.assetid | f6b40060-c17d-472f-b0a3-3b350275d487 | ||||
| caps.latest.revision | 4 | ||||
| author | BYHAM | ||||
| ms.author | rickbyh | ||||
| manager | jhubbard |
[!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]. |
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.
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; 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)