Script to find SQL Server Login group members(Built-In\Administrators)

Posted by

Would you ever asked to find all administrators with sysadmin access in your server then there is a very symple query you can write

SELECT name,sysadmin FROM sys.syslogins 
WHERE sysadmin=1

The above query not just displays the individual logins but also the login groups have admin access

But there are some logins like BUILT-IN\Administrators or some other login groups from your active directory where there are multiple login memebers associated with it, they are called members. then below query is useful to find the members in a login group.

EXEC xp_logininfo 'BUILTIN\Administrators'

The total login from above two queries would be your total login ids having admin access.



Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s