SQL Server: sys.master_files vs. sys.database_files

What is the difference between sys.master_files and sys.database_files? I have about 20 databases in my instance, but when I request sys.master_files, I don't get any rows. What for? When I request sys.database_files, I get information about the database files related to the current database.

+7
database sql-server sql-server-2008 sql-server-2005
source share
1 answer

sys.master_files :

Contains a string on the database file as stored in the main database. This is a single system-wide view.

sys.database_files :

Contains a string in the database file stored in the database itself. This is a view for each database.

So, SELECT * FROM sys.master_files should display files for each database in an instance, while SELECT * FROM sys.database_files should display files for a specific database context.

Testing here (SQL 2K8), does it work as above?

Update: If you do not see the lines from sys.master_files, this may be a permission issue, since the state is BOL:

The minimum permissions required to see the corresponding row are CREATE DATABASE, ALTER ANY DATABASES, or VIEW ANY DEFINITION.

While sys.database_files just requires membership in a public role.

+6
source share

All Articles