SQL ServerStorage
Data and log file size and free space
Size, free space, growth setting and max size for each file in the current database. Run it in the database you're checking.
Not yet verified. How scripts are tested
1SELECT DB_NAME() AS database_name,2 name AS logical_name, type_desc, physical_name,3 size / 128.0 AS size_mb,4 size / 128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS int) / 128.0 AS free_mb,5 CASE max_size WHEN -1 THEN 'Unlimited'6 ELSE CAST(max_size / 128 AS varchar(20)) + ' MB' END AS max_size,7 CASE is_percent_growth WHEN 1 THEN CAST(growth AS varchar(10)) + '%'8 ELSE CAST(growth / 128 AS varchar(20)) + ' MB' END AS growth9FROM sys.database_files;Paste it into your query tool.
More SQL Server scripts: Storage
- Transaction log usage and why it can't truncateLog size and percent used for every database, then the reason each log can't be reused. LOG_BACKUP means log backups aren't running.