我想在具有管理特权的sql服务器中查找角色和权限
答案 0 :(得分:0)
使用IS_SRVROLEMEMBER的旧样式:
SELECT name,type_desc,is_disabled
FROM sys.server_principals
WHERE IS_SRVROLEMEMBER ('sysadmin',name) = 1
ORDER BY name
使用sys.server_role_members
SELECT 'Name' = sp.NAME
, sp.is_disabled AS [Is_disabled]
FROM sys.server_role_members rm
JOIN sys.server_principals sp ON rm.member_principal_id = sp.principal_id
WHERE rm.role_principal_id = SUSER_ID('Sysadmin')
参考: SQL SERVER – Query to Get the List of Logins Having System Admin (sysadmin) Permission