如何在SQL Server中查找具有存储过程的执行权限的所有用户

时间:2014-06-09 17:17:04

标签: sql-server sql-server-2008-r2

...使用SQL Server 2008 R2。我知道如何查找用户有权使用的所有对象,但如何找到对特定对象具有执行权限的所有帐户

2 个答案:

答案 0 :(得分:8)

How Can we find user have Execute Right on SP观察到的以下查询将帮助您获取所需信息(未经过测试..因此可能需要进行小的调整)。

SELECT
s.name AS SchemaName,
o.name AS ObjectName,
dp.name AS PrincipalName,
dperm.type AS PermissionType,
dperm.permission_name AS PermissionName,
dperm.state AS PermissionState,
dperm.state_desc AS PermissionStateDescription
FROM sys.objects o
INNER JOIN sys.schemas s on o.schema_id = s.schema_id
INNER JOIN sys.database_permissions dperm ON o.object_id = dperm.major_id
INNER JOIN sys.database_principals dp 
ON dperm.grantee_principal_id = dp.principal_id
WHERE
dperm.class = 1 --object or column
AND
dperm.type = 'EX'
AND 
dp.name = 'Specific_username'
AND
o.name = 'specific_object_name'

答案 1 :(得分:1)

您没有通过T-SQL或Management Studio指定是否需要它。对于T-SQL,您已经有了答案,对于Management Studio,只需右键单击该对象(例如表,存储过程),单击“属性”,然后选择“权限”选项卡。不要错过蓝色链接"查看架构权限","查看数据库权限","查看服务器权限"。