If you are trying to calculate total disk space in use by all databases within a given MSSQL instance, you can use the following script to determine this space.
SELECT CONVERT(DECIMAL(10,2),(SUM(size * 8.00) / 1024.00 / 1024.00)) As UsedSpace FROM master.sys.master_files
It has been said that “Sys.Master_files is a server-wide view that lists every file in every DB. It’s available from SQL Server 2005 onward.”
Leave a Reply