SQL Server:查看数据库用户权限(SQL 2008)

<p>1. 查看 SQL 2008 用户所属数据库角色</p>
use yourdb
go

select DbRole = g.name, MemberName = u.name, MemberSID = u.sid
  from sys.database_principals u, sys.database_principals g, sys.database_role_members m
 where g.principal_id = m.role_principal_id
   and u.principal_id = m.member_principal_id
 order by 1, 2
go
2. 查看 SQL 2008 登陆帐户所属服务器角色
use master
go

select SrvRole = g.name, MemberName = u.name, MemberSID = u.sid
  from sys.server_principals u, sys.server_principals g, sys.server_role_members m
 where g.principal_id = m.role_principal_id
   and u.principal_id = m.member_principal_id
  order by 1, 2
go
3. 查看 SQL 2008 用户被赋予的权限
use yourdb
go

exec sp_helprotect @username = 'user name'
go
    原文作者:isoleo
    原文地址: https://blog.csdn.net/isoleo/article/details/41728879
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞