IS_ROLEMEMBER

Indicates whether a specified database principle is a member of the specified database role.

Syntax

IS_ROLEMEMBER ( 'role' [ , 'database_principal' ] )

Arguments

' role '

Is the name of the Lyftron role that is being checked. role is sysname.

' database_principal '

Is the name of the database user, database role, or application role to check. database_principal is sysname, with a default of NULL. If no value is specified, the result is based on the current execution context. If the parameter contains the word NULL will return NULL.

Return types

int

Examples

IF IS_ROLEMEMBER ('db_datareader') = 1  
   SELECT CarNo FROM dbo.Cars;

See Also