Created
December 5, 2016 03:13
-
-
Save yang-qu/b3400dfb2d43549c12ad8cb5c0ea82f9 to your computer and use it in GitHub Desktop.
get sql server db size
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT | |
| database_name = DB_NAME(database_id) | |
| , log_size_mb = CAST(SUM(CASE WHEN type_desc = 'LOG' THEN size END) * 8. / 1024 AS DECIMAL(8,2)) | |
| , row_size_mb = CAST(SUM(CASE WHEN type_desc = 'ROWS' THEN size END) * 8. / 1024 AS DECIMAL(8,2)) | |
| , total_size_mb = CAST(SUM(size) * 8. / 1024 AS DECIMAL(8,2)) | |
| FROM sys.master_files WITH(NOWAIT) | |
| --WHERE database_id = DB_ID() -- for current db | |
| GROUP BY database_id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment