问题
I need to give a database user read access to the sys.master_files table. How can I do that?
Currently the user has this permissions:
Calling SELECT on sys.master_files returns an empty result. I also tested the same query with the sa user which works as expected.
回答1:
for you to run successfully
select * from sys.master_files
the minimal permissions that you need to grant is as follows:
GRANT VIEW ANY DEFINITION TO [texas_user]
GO
I have tested and it works fine on sql 2008 r2
regards
marcelo
回答2:
Those server level permissions can also be added by T-SQL script such as :
use master
grant ALTER ANY DATABASE to [texas_user]
grant VIEW ANY DEFINITION to [texas_user]
grant CREATE ANY DATABASE to [texas_user]
The result will be the same: user texas_user will be able to receive results from the sys.master_files. But probably those abilities are some much more than you want. May be, you can receive the same results querying the sys.database_files in the user databases (texas, TexasLog).
来源:https://stackoverflow.com/questions/18911953/how-to-give-a-user-access-to-sys-master-files-in-sql-server