14 November 2006

SQL Server file locations

In MS SQL Server you can get an overview of all database file locations using the 'sysfiles' table. In combination with the stored procedure 'sp_msforeachdb' (which will loop through the databases) you can get a list of all database files used by the SQL Server instance.

USE master
EXEC sp_msforeachdb 'use ? SELECT ''?'' as dbname, filename FROM sysfiles'

No comments: