|
|
Suppose you want to find out the path where the SQL Server database files(mdf and ldf) are located, using a query. You can use system procedure sp_helpdb and system view sysfiles to obtain this information.
The following methods shows the path of the database files for master database
EXEC sp_helpdb master

Method 2 : Use sys.sysfiles view
select filename from master.sys.sysfiles
Did you like this post?
|
|
|
||
|
|
|
|
|
|
|
subscribe via rss |
|
subscribe via e-mail |
|
|
print this post |
|
follow me on twitter |






comments
2 Responses to "SQL Server: Find Database File Path"For SQL Server 2005+ you can also use sys.database_files:
SELECT name, physical_name
FROM sys.database_files
I am not 100% sure but I think sys.sysfiles was either removed or planned to be removed from SQL 2005+ onwards. So yes sys.database_files is a good option.
For read-only db's in particular, I would recommend trying the master.sys.master_files DMV.
Post a Comment