Hi,
I executed the below query and getting the capacity values only for master database.All other DB shows NULL values for spaceused.
I'm acutally looking for a query to get all the capacity information other than using temp table and the procedures.
Is there any way using SQL query ONLY.
selectdb.[dbid] as 'DB ID',
db.[name] as 'Database Name',
af.[name] as 'Logical Name',
convert(decimal(12,2),round(size/128.000,2)) as FileSizeMB,
convert(decimal(12,2),round(fileproperty(db.name,'SpaceUsed')/128.000,2)) as SpaceUsedMB
from sys.sysdatabases db
inner join sys.sysaltfiles af
on db.dbid = af.dbid
Below is the output
DB ID Database Name Logical Name FileSizeMB SpaceUsedMB1 master master 4.00 3.44
1 master mastlog 2.00 3.44
2 tempdb tempdev 8.00 NULL
2 tempdb templog 0.50 NULL
3 model modeldev 2.19 NULL
3 model modellog 0.75 NULL
4 msdb MSDBData 14.13 NULL
4 msdb MSDBLog 0.75 NULL
5 ReportServer ReportServer 5.19 NULL
5 ReportServer ReportServer_log 6.88 NULL
6 ReportServerTempDB ReportServerTempDB 4.19 NULL
6 ReportServerTempDB ReportServerTempDB_log 1.06 NULL
7 MyAdventureWorks AdventureWorks2012_Data 205.00 NULL
7 MyAdventureWorks AdventureWorks2012_Log 1.00 NULL