How to give a user access to sys.master_files in SQL Server?

落爺英雄遲暮 提交于 2019-12-08 17:34:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!