Friday, 18 May 2012

Sql server scripts : Get SQL Server Database Physical file Location and file size using sql script

Some time you Database Physical file Address and file size using sql script.

SQL Script :
SELECT DB_NAME(database_id) AS DatabaseName,Name AS Logical_Name,Physical_Name,(size*8)/1024 Size_MB
FROM sys.master_files

You can also query for particular database name like :
SELECT DB_NAME(database_id) AS DatabaseName,Name AS Logical_Name,Physical_Name,(size*8)/1024 Size_MB
FROM sys.master_files
WHERE DB_NAME(database_id) = 'TempDatabase'

Output :

(To view original image , click on image)

No comments:

Post a Comment