如何在具有管理特权的sql服务器中找到角色和权限

时间:2020-10-08 07:13:45

标签: sql sql-server admin roles sql-function

我想在具有管理特权的sql服务器中查找角色和权限

1 个答案:

答案 0 :(得分:0)

  1. 使用IS_SRVROLEMEMBER的旧样式:

    SELECT   name,type_desc,is_disabled
    FROM     sys.server_principals 
    WHERE    IS_SRVROLEMEMBER ('sysadmin',name) = 1
    ORDER BY name
    
  2. 使用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