Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

select * from sys.database_files

Posted on 2013-01-16
2
Medium Priority
?
751 Views
Last Modified: 2013-01-16
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
Comment
Question by:johndarby
2 Comments
 
LVL 23

Accepted Solution

by:
Steve Wales earned 2000 total points
ID: 38784988
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
 
LVL 1

Author Closing Comment

by:johndarby
ID: 38785011
That is awesome; thank you!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question