Size of your Database in MB,GB,TB


Hi All,

Below is the script for finding the database Size in MB,GB,TB

I am taking the adventure works DB as sample example

USE master

Go

SELECT DB_NAME(database_id) AS DatabaseName,

Name AS Logical_Name,

Physical_Name

,SUM((((CAST([size] as DECIMAL(18,4)) * 8192) /1024) /1024)) as ‘File Size (MB)’

,sum((((CAST([size] as DECIMAL(18,4)) * 8192) /1024) /1024)/1024) as ‘File Size (GB)’

,sum(((((CAST([size] as DECIMAL(18,4)) * 8192) /1024) /1024) /1024/1024)) as ‘File Size (TB)’

FROM sys.master_files

WHERE DB_NAME(database_id) IN(‘AdventureWorks2012’)

GROUP BY DB_NAME(database_id),Name ,Physical_Name WITH ROLLUP

Please check and let us know if you have any concerns on this.

Thanks for viewing this.

Regards,

Chaitanya

Visit site: http://www.sqlblogging.com

Send an Email: sqlblogging

2 responses

  1. Lazaro's avatar

    I see a lot of interesting content on your page. You have
    to spend a lot of time writing, i know how to save you
    a lot of work, there is a tool that creates readable,
    google friendly articles in couple of seconds, just type
    in google – k2 unlimited content

    Like

Leave a comment

Design a site like this with WordPress.com
Get started