I want to calculate how much space my databases are using in a server. I could use sp_spacefiles or query sys.databases table but that would give me separate results for each database and I would have to copy that into an excel sheet and calculate the sum from there.
Is there a direct way of doing it in T-SQL?
Thanks.
You can query
master.sys.master_files:This will give you a total in GB.
Sys.Master_filesis a server-wide view that lists every file in every DB. It’s available from SQL Server 2005 onward.