开发者

user permission list

开发者 https://www.devze.com 2023-01-25 03:09 出处:网络
Can anybody help me on this? How开发者_Go百科 to get the database level permission users list for a particular database in SQL Server 2005?Simple Google search, with query taken from the first result

Can anybody help me on this?

How开发者_Go百科 to get the database level permission users list for a particular database in SQL Server 2005?


Simple Google search, with query taken from the first result:

 select dp.NAME AS principal_name,
         dp.type_desc AS principal_type_desc,
         o.NAME AS object_name,
         p.permission_name,
         p.state_desc AS permission_state_desc
 from    sys.database_permissions p
 left    OUTER JOIN sys.all_objects o
 on     p.major_id = o.OBJECT_ID
 inner   JOIN sys.database_principals dp
 on     p.grantee_principal_id = dp.principal_id

Modified slightly to include the database name as well:

select dp.NAME AS principal_name,
    dp.type_desc AS principal_type_desc,
    o.NAME AS object_name,
    p.permission_name,
    p.state_desc AS permission_state_desc,
    d.[name] as database_name
from sys.database_permissions p
left OUTER JOIN sys.all_objects o on p.major_id = o.OBJECT_ID
inner JOIN sys.database_principals dp on p.grantee_principal_id = dp.principal_id
left outer JOIN sys.sysdatabases d on d.sid = dp.sid 
0

精彩评论

暂无评论...
验证码 换一张
取 消