This article is half-done without your Comment! *** Please share your thoughts via Comment ***
The SQL Server log and its maintenance are one of the important tasks for a Database Administrator.
There are many optimized ways to configured SQL Server log, but then also we have to monitor the size of SQL Server logs.
Before SQL Server 2012, we have different methods to find size of SQL Server Database Log like DBCC commands, but now SQL Server 2012 introduced new dynamic management view name is dm_db_log_space_usage and using this dm-view we can quickly calculate the size of the SQL Server Database log.
Below is a script to find the size of the SQL Server Database log.
1 2 3 4 5 6 7 |
SELECT DB_NAME(database_id) AS DatabaseName ,ROUND(CONVERT(FLOAT,total_log_size_in_bytes/1024)/1024,2) AS LogSizeInMB ,ROUND(CONVERT(FLOAT,used_log_space_in_bytes/1024)/1024,2) AS LogUsedSizeInMB ,ROUND(used_log_space_in_percent,2) AS LogUsedPercentInMB FROM sys.dm_db_log_space_usage |