How To Check Database Size In Sql Server?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
1. To view the size of a specific database, you can use the sp_helpdb stored procedure:
EXEC sp_helpdb ‘DatabaseName’
2. To view the size of all databases, you can use the sys.databases system view:
SELECT name, size/128.0 AS [Size in MB]
FROM sys.master_files;
3. To view the size of all databases including log files, you can use the sys.dm_db_partition_stats dynamic management view:
SELECT DB_NAME(database_id) AS DatabaseName
,file_id
,SUM(size_on_disk_bytes)/128.0 AS [Size in MB]
FROM sys.dm_db_partition_stats
GROUP BY DB_NAME(database_id), file_id;