Tuesday, June 11, 2013

Check the size of database files in SQL Server

How can we check the size of particular database files like .ldf and .mdf?

We can check the size which is occupied by the database files using the sys.database_files view.

To check the size of database files .ldf and .mdf use the below query:

use databasename

       Name AS DatabaseName
      ,Physical_name AS DBPath
      ,(size * 8)/1024 AS SizeMB
FROM sys.database_files


Here it shows the Database file name with location of file and size in MB unit.

No comments: