sql check roles

Solutions on MaxInterview for sql check roles by the best coders in the world

showing results for - "sql check roles"
Elena
02 Jan 2021
1USE master  
2GO  
3SELECT DP1.name AS DatabaseRoleName,   
4   isnull (DP2.name, 'No members') AS DatabaseUserName   
5 FROM sys.database_role_members AS DRM  
6 RIGHT OUTER JOIN sys.database_principals AS DP1  
7   ON DRM.role_principal_id = DP1.principal_id  
8 LEFT OUTER JOIN sys.database_principals AS DP2  
9   ON DRM.member_principal_id = DP2.principal_id  
10WHERE DP1.type = 'R'
11ORDER BY DP1.name;