Determine Roles and Privileges Granted to a User

The sp_has_role stored function returns an integer value which indicates whether the invoker of the procedure has been granted the specified system privilege or user-defined role.

No system privileges are required to execute the function. When used for permission checking within user-defined stored procedures, this function can display an error message when a user fails a permission check.

Related reference
SP_HAS_ROLE Function [System]