Indicates whether the current user login is a member of the specified server role.
IS_SRVROLEMEMBER ( 'role' [,'login'])
Valid values for role are:
int
IS_SRVROLEMEMBER returns these values.
Return value | Description |
---|---|
0 | login is not a member of role. |
1 | login is a member of role. |
NULL | role or login is not valid. |
This function can be useful to programmatically detect whether the current user can perform an activity requiring the server role’s permissions.
If a Windows NT user, such as London\JoeB, is specified for login, IS_SRVROLEMEMBER returns NULL if the user has not previously been granted or denied direct access to Microsoft SQL Server using sp_grantlogin or sp_denylogin.
This example indicates whether the current user is a member of the sysadmin fixed server role.
IF IS_SRVROLEMEMBER ('sysadmin') = 1
print 'Current user''s login is a member of the sysadmin role'
ELSE IF IS_SRVROLEMEMBER ('sysadmin') = 0
print 'Current user''s login is NOT a member of the sysadmin role'
ELSE IF IS_SRVROLEMEMBER ('sysadmin') IS NULL
print 'ERROR: Invalid server role specified'
IS_MEMBER | Security Functions |