In this post, I am providing an SQL Script to find the size of Database Files and Log Files in SQL Server.
I am calculating this size using sys.master_files and perform require division to get size in MB and GB because it is returning 8 KB pages.
The Database Administrator can use this script to get quick size of Database Files and Log Files of a SQL Server. SQL Server Management Studio also provides GUI tools, but still I always use different script to do my DBA task.
db_name(database_id) AS DatabaseName
,type_desc AS TypeDesc
,(size * 8) /1024 AS SizeInMB
,(size * 8) /1024/1024 AS SizeInGB
ORDER BY name