Quantcast
Channel: SQL Steve » SQL Server 2008
Viewing all articles
Browse latest Browse all 20

How to: Determine SQL Server Transaction Log Space Usage

$
0
0

I have a client that recently asked me if the transaction log of one of his databases was being truncated on a regular basis.  The database was using the “simple” recovery model and as such is truncated automatically on a regular basis – however it is always nice to provide empirical proof when possible.

So – I assembled the following simple query to show the size of the transaction log bytes as well as the percent space used.

SELECT
    size* 8 ASFileSize,
    FILEPROPERTY(name,‘SpaceUsed’)* 8 ASUsedSpace,
    FILEPROPERTY(name,‘SpaceUsed’)/CONVERT(MONEY,size)* 100 ASPercentUsed
FROM
    sys.database_files
WHERE
    type_desc=‘LOG’

 

This query of course must be run within the context of the database you wish to analyze.

That’s it for today’s post.  Check back tomorrow for more goodies!


Filed under: SQL Server, SQL Server 2005, SQL Server 2008, SQL Server 2012, T-SQL Tagged: Space Used, SQL Server, Transaction Log

Viewing all articles
Browse latest Browse all 20

Trending Articles