• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 770
  • Last Modified:

select * from sys.database_files

I have a query which allows me to see each database's physical files. Is there a similar query to see physical locations of all databases on a SQL server?

Thank you!
JohnD
0
John Darby
Asked:
John Darby
1 Solution
 
Steve WalesSenior Database AdministratorCommented:
Well, the files (usually, if held to accepted and recommended naming conventions a minimum of a .MDF and a .LDF file) are what makes up the physical location of the databases.

So what you're seeing in sys.database_files is it, per database.

To see all of them:

exec msdb..sp_msforeachdb 'use [?]; select * from [?].sys.database_files'

Open in new window


Of course, you could replace 'select *' with a selected list of the columns you want to see.

Oh, and here's the entry from the documentation on this view which is a per database view:

http://msdn.microsoft.com/en-us/library/ms174397.aspx
0
 
John DarbyPMAuthor Commented:
That is awesome; thank you!
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now