Solved

select * from sys.database_files

Posted on 2013-01-16
2
700 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 22

Accepted Solution

by:
Steve Wales earned 500 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

832 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