The sp_has_role stored function
returns an integer value that 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.
- 1 – indicates the system privilege or user-defined role is
granted to the invoking user.
- 0 or Permission denied: you do not have permission to execute this
command/procedure – indicates the system privilege or user-defined role is not
granted to the invoking user. The error message replaces the value 0 when
the throw_error argument is set to 1.
- -1 – indicates the system privilege or user-defined role
specified does not exist. No error message appears, even if the throw_error
argument is set to 1.