Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 776
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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