How can I view all grants for an SQL Database?

前端 未结 5 927
无人共我
无人共我 2020-12-31 00:49

I am using SQL Server 2005, I want to find out what all the grants are on a specific database for all tables. It would also help to find out all tables where the delete gran

5条回答
  •  天涯浪人
    2020-12-31 01:36

    To list all the permissions that can be controlled you can use the function fn_my_permission. This query lists all permissions on server:

    select * from fn_my_permissions(NULL, NULL)
    

    You have to login using an account that has sysadmin role.

    You can refine the function calls using following parameters.

    For all permissions on database:

    select * from fn_my_permissions(NULL, 'database')
    

    For all permissions on the dbo schema:

    select * from fn_my_permissions('dbo', 'schema')
    

    For all permissions on a table:

    select * from fn_my_permissions('dbo.test', 'object')
    

提交回复
热议问题