Sunday, January 31, 2010

Know transaction log file size and free space for all databases

The best way to get transaction log file’s total size and free space in percentage for all databases is using the old  DBCC SQLPERF(LOGSPACE) command.

To know the total size and space used by all files (data files and log file) of a database (current database only) use the below query:

select name, size*8 as total, 
FILEPROPERTY (name, 'spaceused')*8 as used, 
((size*8) - (FILEPROPERTY (name, 'spaceused')*8))*100/(size*8) as [free space percentage], [filename]  
from sys.sysfiles

No comments: