Creates a new Microsoft® SQL Server™ role in the current database.
sp_addrole [@rolename =] 'role' [,[@ownername =] 'owner']
0 (success) or 1 (failure)
SQL Server roles can contain from 1 to 128 characters, including letters, symbols, and numbers. However, roles cannot:
After adding a role, use sp_addrolemember to add security accounts as members of the role. When using the GRANT, DENY, or REVOKE statements to apply permissions to the role, members of the role inherit the permissions as if the permissions were applied directly to their accounts.
Note It is not possible to create new fixed server roles. Roles can only be created at the database level.
sp_addrole cannot be used inside a user-defined transaction.
Only members of the sysadmin fixed server role or db_securityadmin and db_owner fixed database roles can execute sp_addrole.
This example adds the new role called Managers to the current database.
EXEC sp_addrole 'Managers'
Creating User-Defined SQL Server Database Roles | sp_helprole |
sp_addrolemember | System Stored Procedures |
sp_droprole |