Quantcast
Viewing all articles
Browse latest Browse all 17

How to: Determine SQL Server Transaction Log Space Usage

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 Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 17

Trending Articles