Search This Blog

Find the Size of Database

I encountered the situation recently where I needed to find the size of the database.

--size of database 
SELECT DB_NAME(database_id) AS DatabaseName,SUM((size*8)/1024) SizeInMB
FROM sys.master_files
GROUP BY DB_NAME(database_id) 
-- size of individual db files
SELECT DB_NAME(database_id) AS DatabaseName,
Name AS Logical_Name,
Physical_Name, (size*8)/1024 SizeInMB
FROM sys.master_files

No comments: