Search This Blog

Tuesday, 29 November 2016

MSQL database ​size in MB/GB query​ with creation date.

SELECT d.NAME, create_date,
    ROUND(SUM(mf.size) * 8 / 1024, 0) Size_MBs
    ,(SUM(mf.size) * 8 / 1024) / 1024 AS Size_GBs
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,create_date
ORDER BY d.NAME

No comments:

Post a Comment