Transact-SQL Reference

sp_addapprole

Adds a special type of role in the current database used for application security.

Syntax

sp_addapprole [ @rolename = ] 'role'
    ,
[ @password = ] 'password'

Arguments

[ @rolename = ] 'role'

Is the name of the new role. role is sysname, with no default. role must be a valid identifier and cannot already exist in the current database.

[ @password = ] 'password'

Is the password required to activate the role. password is sysname, with no default. password is stored in encrypted form.

Return Code Values

0 (success) or 1 (failure)

Remarks

Microsoft® SQL Server™ roles can contain from 1 through 128 characters, including letters, symbols, and numbers. However, roles cannot:

The fundamental differences between standard and application roles are:

sp_addapprole cannot be executed from within a user-defined transaction.

Permissions

Only members of the sysadmin fixed server role, and the db_owner and db_securityadmin fixed database roles can execute sp_addapprole.

Examples

This example adds the new application role SalesApp to the current database with the password xyz_123.

EXEC sp_addapprole 'SalesApp', 'xyz_123'

See Also

Application Security and Application Roles

Rules for SQL Server Logins, Users, Roles, and Passwords

sp_dropapprole

sp_setapprole

System Stored Procedures