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
