sp_adduser

Description

Adds a new user to the current database.

Syntax

sp_adduser loginame [, name_in_db [, grpname]]

Parameters

loginame

is the user’s name in master.dbo.syslogins.

name_in_db

is a new name for the user in the current database.

grpname

adds the user to an existing group in the database.

Examples

Example 1

Adds “margaret” to the database. Her database user name is the same as her Adaptive Server login name, and she belongs to the default group, “public”:

sp_adduser margaret

Example 2

Adds “haroldq” to the database. When “haroldq” uses the current database, his name is “harold.” He belongs to the fort_mudge group, as well as to the default group “public”:

sp_adduser haroldq, harold, fort_mudge

Usage

Permissions

Only the database owner, a system administrator, or a system security officer can execute sp_adduser.

Auditing

Values in event and extrainfo columns from the sysaudits table are:

Event

Audit option

Command or access audited

Information in extrainfo

38

exec_procedure

Execution of a procedure

  • Roles – Current active roles

  • Keywords or options – NULL

  • Previous value – NULL

  • Current value – NULL

  • Other information – All input parameters

  • Proxy information – Original login name, if set proxy in effect

See also

Commands grant, revoke, use

System procedures sp_addalias, sp_addgroup, sp_changegroup, sp_dropalias, sp_dropgroup, sp_helpuser