Monthly Archives: July 2018

How to tell if you are a member of a SQL Server group or create a list of group members using T-SQL

The following scripts will help you determine if you are a member of a group or role or create a list of group members in SQL Server without having to use SQL Server Management Studio. This is a particularly handy script in determining who might have access to the server through Active Directory groups.

The code below indicates whether the current user is a member 
of the specified Microsoft Windows group or SQL Server database role.
A result of 1 = yes
,0 = no
,null = the group or role queried is not valid.

SELECT IS_MEMBER('group or role')


SELECT IS_MEMBER('db_owner')

The code below will create a list of all the logins that are members 
of a group. Don't forget to include domain, e.g. admin\user

EXEC master..xp_logininfo 
@acctname = [group],
@option = 'members'