Which login has what server role permissions

Below script will query sys.server_role_members / sys.server_principals to find out which logins have what server role access.

Code:

SELECT 'ServerRole' = CASE
WHEN rm.role_principal_id > 2 THEN SUSER_NAME(rm.role_principal_id) END,
lgn.name AS 'MemberName',
'Login Create Date'=Convert(VARCHAR(24),Create_Date,126)
FROM sys.server_role_members AS rm RIGHT OUTER JOIN
sys.server_principals AS lgn ON rm.member_principal_id = lgn.principal_id
WHERE (lgn.principal_id <= 1 OR lgn.principal_id > 10) AND lgn.type <> 'C'
ORDER BY ServerRole DESC, MemberName

You could download it here

CU
tosc

SQL Server 2005 Books Online Scoped Search for: sys.server_role_members
sys.server_principals

No feedback yet
Leave a comment

Your email address will not be revealed on this site.
PoorExcellent
(Line breaks become <br />)
(For my next comment on this site)
(Allow users to contact me through a message form -- Your email will not be revealed!)
This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case sensitive)
Trackback address for this post
This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case sensitive)