| Subject: |
SQL Server 2005: Show all databases and their file location |
| Updated: |
May-12-2007 |
| Rating: |
Not Rated |
| By: |
Rocky Moore - Member #: 1 |
| Location: |
Klamath Falls, Oregon USA |
| Website: |
www.RockyMoore.com |
| Category: |
Computers > Programming > Databases |
Today, I have to do a clean reinstall of the OS. I needed to make sure I grab all the databases located on the machine regardless of where they are located. They all should be in a specific folder, but to make sure I went in to get the path and file name for all the databases. There are a number of databases and clicking on each database, selecting properties and then looking at the file groups would take a bit of time.
To expedite the process, I threw together this query. Maybe it will be helpful to others:
select
m.database_id, m.name, physical_name
from
sys.master_files as m join sys.databases as d
on m.database_id = d.database_id
Trivial, but handy!
[Submit DIGG for this tip]
-----------
Note: Use the tips posted on this site at your own risk.
The tips are posted by the public and as such may or may not be valid.