How to list role members in SQL Server 2008 R2

前端 未结 3 1599
猫巷女王i
猫巷女王i 2021-02-01 05:38

I\'m using the following T-SQL to obtain role members from my SQL Server 2008 R2 database:

select rp.name as database_role, mp.name as database_user
from sys.dat         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-01 05:44

    Here is another way

    SELECT dp.name , us.name  
    FROM sys.sysusers us right 
    JOIN  sys.database_role_members rm ON us.uid = rm.member_principal_id
    JOIN sys.database_principals dp ON rm.role_principal_id =  dp.principal_id
    

提交回复
热议问题