Great minds discuss ideas !


Physical file location for all the databases in SQL Server


Very often DBAs need to find the location of the physical file (MDF, LDF & NDF) of a database. Simply we can obtain the output by executing the below query. Run the script to get the SQL Server database file location for all the databases for a particular instance.

Script to find the physical file location

SELECT as [Database], as [File Name], DBM.physical_name as [File Location]
from sys.databases DBS inner join sys.master_files DBM ON DBS.database_id = DBM.database_id
WHERE DBS.database_id>4


Physical File Location

Leave a Reply