Tuesday, March 20, 2012

Query to return database file names and locations

Does anyone know a query that will return all the databases (SQL 2005) on a server with their file names and locations?

Thanks

You could always just use the standard sp_helpdb.

EXEC sp_helpdb <dbname>

|||

In SQL SERVER 2005, catalog view sys.master_files exposes this information.

So,

select db_name(database_id) database_name, * from sys.master_files

will return all database file names and locations (except resource database)

No comments:

Post a Comment