:::: MENU ::::

Find all logins with sysadmin role

Potentially a great big security problem is having more than just one or a few logins with sysadmin role, try to keep the list as short as possible, find all of them with this script:

SELECT	p.name AS [Name] ,r.type_desc,r.is_disabled,r.create_date , r.modify_date,r.default_database_name
FROM	sys.server_principals r
INNER JOIN sys.server_role_members m ON r.principal_id = m.role_principal_id
INNER JOIN sys.server_principals p ON p.principal_id = m.member_principal_id
WHERE	r.type = 'R' 
AND    r.name = N'sysadmin'

//R


So, what do you think ?