IS_MEMBER
Indicates whether the current user is a member of the specified Microsoft® Windows NT® group or Microsoft SQL Server™ role.
Syntax
IS_MEMBER ( { 'group' | 'role' } )
Arguments
'group'
Is the name of the Windows NT group being checked; must be in the format Domain\Group. group is sysname.
'role'
Is the name of the SQL Server role being checked. role is sysname and can include the database fixed roles or user-defined roles but not server roles.
Return Types
int
Remarks
IS_MEMBER returns these values.
Return value | Description |
---|---|
0 | Current user is not a member of group or role. |
1 | Current user is a member of group or role. |
NULL | Either group or role is not valid. |
This function can be useful to programmatically detect whether the current user can perform an activity that depends on the permissions applied to a group or role.
Examples
This example indicates whether the current user is a member of the db_owner fixed database role.
IF IS_MEMBER ('db_owner') = 1
print 'Current user is a member of the db_owner role'
ELSE IF IS_MEMBER ('db_owner') = 0
print 'Current user is NOT a member of the db_owner role'
ELSE IF IS_MEMBER ('db_owner') IS NULL
print 'ERROR: Invalid group / role specified'