Thursday, October 29, 2020

SQL PAR LIST

 --List of Sysadmin

SELECT 'Name' = sp.NAME

    ,sp.is_disabled AS [Is_disabled]

FROM sys.server_role_members rm

    ,sys.server_principals sp

WHERE rm.role_principal_id = SUSER_ID('Sysadmin')

    AND rm.member_principal_id = sp.principal_id;



 --List of role members

 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'





--dumps


select * from sys.server_role_members;


select * from sys.server_principals;


select * from  sys.database_role_members;


select * from  sys.database_principals;

No comments:

Post a Comment