Thursday, 16 June 2016

SQL querry to get the Database sizes

SQL query to get the Database sizes 
Use below SQL Script to get all DB sizes in MB
----------------------------------------------------------------------------------
SELECT d.name,
ROUND(SUM(mf.size) * 8 / 1024, 0) Size_MBs
FROM sys.master_files mf
INNER JOIN sys.databases d ON d.database_id = mf.database_id
WHERE d.database_id > 4 -- Skip system databases
GROUP BY d.name
ORDER BY d.name
-----------------------------------------------------------------------------------
You will get the .csv output by executing the query, the DB size will be in MB you can convert into GB

No comments:

Post a Comment