How to view the roles and permissions granted to any database user in Azure SQL server instance?

前端 未结 4 380
遥遥无期
遥遥无期 2021-01-30 17:18

Could you guide me on how to view the current roles/permissions granted to any database user in Azure SQL Database or in general for a MSSQL Server instance?

I have thi

4条回答
  •  遇见更好的自我
    2021-01-30 17:45

    To view database roles assigned to users, you can use sys.database_role_members

    The following query returns the members of the database roles.

    SELECT DP1.name AS DatabaseRoleName,   
        isnull (DP2.name, 'No members') AS DatabaseUserName   
    FROM sys.database_role_members AS DRM  
    RIGHT OUTER JOIN sys.database_principals AS DP1  
        ON DRM.role_principal_id = DP1.principal_id  
    LEFT OUTER JOIN sys.database_principals AS DP2  
        ON DRM.member_principal_id = DP2.principal_id  
    WHERE DP1.type = 'R'
    ORDER BY DP1.name;  
    

提交回复
热议问题