Friday, September 30, 2011

SQL Tip - List all databases file path

Today, @ work, I needed to find out the physical file location for .mdf and .ldf files of all our databases on SQL

Just fire this query in SSMS Query Editor

SELECT name, physical_name FROM sys.master_files

Output:

It will return you the database names alongwith physical paths

To read more about sys.master_files and the additional columns, read here http://msdn.microsoft.com/en-us/library/ms186782.aspx

1 comment:

  1. It works! Thank you!

    Just a quick question. Why it shows some databases that do not exist anymore?

    http://i53.tinypic.com/20f7xp1.jpg

    ReplyDelete