Returns information about whether the user has been granted a specified role.
proc_role("role_name")
create procedure sa_check as if (proc_role("sa_role") > 0) begin print "You are a System Administrator." return(1) end
select proc_role("sso_role")
select proc_role("oper_role")
Using proc_role with a procedure that starts with “sp_” returns an error.
proc_role, a system function, checks whether an invoking user has been granted, and has activated, the specified role.
Not been granted the specified role
Not been granted a role which contains the specified role
Been granted, but has not activated, the specified role
proc_role returns 1 if the invoking user has been granted, and has activated, the specified role.
proc_role returns 2 if the invoking user has a currently active role, which contains the specified role.
alter role, create role, drop role, grant, revoke, set in Reference Manual: Commands
Transact-SQL Users Guide
ANSI SQL – Compliance level: Transact-SQL extension.
Any user can execute proc_role.