Wednesday 22 June 2016

Calculate Database Size in SQL server Syntax


One of the best way to calculate size of all database using SQL server management studio query editor.

SELECT      sys.databases.name,
            CONVERT(VARCHAR,SUM(size)*8/1024)+' MB' AS [Total disk space]
FROM        sys.databases 
JOIN        sys.master_files
ON          sys.databases.database_id=sys.master_files.database_id
GROUP BY    sys.databases.name
ORDER BY    sys.databases.name

--or 

exec sp_spaceused 



You may look for Calculate all tables Size in database in SQL server Syntax.