SQL Server: sys.master_files vs. sys.database_files

sys.master_files :

Contains a row per file of a database as stored in the master database. This is a single, system-wide view.

sys.database_files :

Contains a row per file of a database as stored in the database itself. This is a per-database view.

So, SELECT * FROM sys.master_files should list the files for each database in the instance whereas SELECT * FROM sys.database_files should list the files for the specific database context.

Testing this here (SQL 2K8), it works as per the above?

Update: If you're not seeing rows from sys.master_files, it could be a permissions issue as BOL states:

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

Whereas for sys.database_files just requires membership in the public role.

Share:
Admin
Author by

Admin

Updated on July 25, 2022

Comments

  • Admin
    Admin 12 days

Related