sp_addapprole (T-SQL)

Adds a special type of role in the current database, which is 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 to 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 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 sp_setapprole
Rules for SQL Server Logins, Users, Roles, and Passwords System Stored Procedures
sp_dropapprole  

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.