What’s the size of my SQL Server database?

1160680 pts.
Tags:
Database
SQL Server
My apologizes for the short question but can I find out what the size is of my SQL Server database? This would include tables, logs, etc.
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

To get database size
information, use 
sys.master_files catalog view

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

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • AjitK29

    You'll probably want to start with the sp_spaceused command.

    For example:

    sp_spaceused Returns information about the total size of the database

    2,545 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: