sp_changegroup

Description

Changes a user’s group.

Syntax

sp_changegroup grpname, username

Parameters

grpname

is the name of the group. The group must already exist in the current database. If you use “public” as the grpname, enclose it in quotes, because it is a keyword.

username

is the name of the user to be added to the group. The user must already exist in the current database.

Examples

Example 1

The user “albert” is now a member of the “fort_mudge” group. It doesn’t matter what group “albert” belonged to before:

sp_changegroup fort_mudge, albert

Example 2

Removes “albert” from the group he belonged to without making him a member of a new group (all users are always members of “public”):

sp_changegroup "public", albert

Usage

Permissions

Only the Database Owner, a System Administrator, or a System Security Officer can execute sp_changegroup.

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

System procedures sp_addgroup, sp_adduser, sp_dropgroup, sp_helpgroup