Database File Size Stats
--Using original Query: select DB_NAME ( database_id ) as dbname , m . name , m . physical_name , m . type_desc , m . size / 128.0 "Initial Size (MB)" , d . size / 128.0 "current Size (MB)" , ( fileproperty ( m . name , 'spaceused' ))/ 128.0 "Used (MB)" from sys . master_files m , sys . database_files d where database_id = DB_ID() and m . file_id = d . file_id --Using sp_MSforeachdb: exec sp_MSforeachdb N'USE ? select DB_NAME(database_id) as dbname, m.name, m.physical_name, m.type_desc, m.size / 128.0 "Initial Size (MB)" , d.size / 128.0 "current Size (MB)", (fileproperty(m.name, ''spaceused''))/128.0 "Used (MB)" from sys.master_files m, sys.database_files d where database_id = DB_ID() and m.file_id = d.file_id' --Using Cursor: IF OBJECT_ID('tempdb..#TempTable') IS NOT NULL DROP TABLE #TempTable; PRINT'check for user database fi