sp_changegroup System Stored Procedure

Changes a user's group.

Syntax

sp_changegroup grpname, username

where

grpname
Is the name of a group that already exists in the current database.
username
Specifies which user to add to the group. The user must already exist in the current database.

Remarks

Groups provide a collective name that is used when granting and revoking permissions. A user can be a member of only one group, in addition to public.

The sp_changegroup system stored procedure adds the specified user to the specified group. The user is dropped from the group he or she belongs to and is added to the one specified by grpname. If you use public as the grpname parameter, it must be enclosed in quotation marks because PUBLIC is an SQL keyword.

New database users can be added to groups at the same time as they are given access to the database by sp_adduser.

Every user is a member of the default group public, if not explicitly added to some other group by sp_adduser or sp_changegroup.

Example

This example makes Albert a member of the developers group. It doesn't matter which group Albert belonged to before.

sp_changegroup developers, Albert

Permission

Execute permission defaults to the database owner.

Table Used

sysusers

See Also

GRANT sp_adduser
REVOKE sp_dropgroup
sp_addgroup sp_helpgroup