Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions Links


SQL Server DBA Jobs

SQL Server - Find the Database File Size and Log File Size

17 September,2012 by Tom Collins

A quick way to to find the Database File Size and Log File Size, by querying the sys.master_files.size column.

The sys.master_files.size column returns the file size in 8 KB pages.  Therefore some division is required to calculate in MB and GB.

If the sys.master_files = ROWS it’s a data file . If the sys.master_files = LOGS it’s a log file .


select db_name(database_id) as dbname,
type_desc,(size * 8) /1024 as size_MB,
(size * 8) /1024/1024 as size_GB 
from sys.master_files order by name

 Related Posts

Attach database without log file and rename database

SQL Server – files and filegroups. Improving database performance

Author: Tom Collins (


Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.


Post a comment on SQL Server - Find the Database File Size and Log File Size | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer