Issue
Time to time is necessary to check the size of the database (data & log files)
Solution
To discover the size of the databases, please use sql queries below:
Run those queries on the “master”
–query to find out the size of the databases in MB

with fs
as
(
select database_id, type, size * 8.0 / 1024 size
from sys.master_files
)
select
name,
(select sum(size) from fs where type = 0 and fs.database_id = db.database_id) DataFileSizeMB,
(select sum(size) from fs where type = 1 and fs.database_id = db.database_id) LogFileSizeMB
from sys.databases db

–query to find out the size of the databases in GB

with fs
as
(
select database_id, type, size * 8.0 / 1024 / 1024 size
from sys.master_files
)
select
name,
(select sum(size) from fs where type = 0 and fs.database_id = db.database_id) DataFileSizeGB,
(select sum(size) from fs where type = 1 and fs.database_id = db.database_id) LogFileSizeGB
from sys.databases db
Print Friendly, PDF & Email