Many times we want to find the total disk space used by all the files in a particular database. It can happen that we have a database that is having many secondary data files for performance gains and now we want to determine the total disk space (Free space as well as Used Space) used by the files .

In this scenario we can use the following query:

USE AdventureWorks


SELECT SUM(size)*1.0/128 AS [size in MB]
FROM sys.database_files


Subhro Saha