| title | sys.dm_db_log_space_usage (Transact-SQL) | Microsoft Docs | ||||
|---|---|---|---|---|---|
| ms.custom | |||||
| ms.date | 06/29/2017 | ||||
| ms.prod | sql | ||||
| ms.prod_service | database-engine, sql-database | ||||
| ms.reviewer | |||||
| ms.technology | system-objects | ||||
| ms.topic | conceptual | ||||
| f1_keywords |
|
||||
| dev_langs |
|
||||
| helpviewer_keywords |
|
||||
| ms.assetid | f6b40060-c17d-472f-b0a3-3b350275d487 | ||||
| author | stevestein | ||||
| ms.author | sstein | ||||
| manager | craigg | ||||
| monikerRange | =azuresqldb-current||>=sql-server-2016||=sqlallproducts-allversions||>=sql-server-linux-2017||=azuresqldb-mi-current |
[!INCLUDEtsql-appliesto-ss2012-asdb-xxxx-xxx-md]
Returns space usage information for the transaction log.
Note
All transaction 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_md], requires VIEW SERVER STATE permission.
On [!INCLUDEssSDS_md], requires the VIEW DATABASE STATE permission in the database.
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)
sys.dm_db_log_info (Transact-SQL)
sys.dm_db_log_stats (Transact-SQL)