Changes the role membership for the security account of a user in the current database. This procedure is provided for backward compatibility. Microsoft® SQL Server™ version 7.0 uses roles instead of groups. Use sp_addrolemember instead.
sp_changegroup [@grpname =] 'role', [@username =] 'user'
0 (success) or 1 (failure)
Roles provide a mechanism for managing the permissions applied to the members of the role. When adding a user to a role, the user gains the permissions defined for the role.
When sp_changegroup is executed, the security account for user is added as a member of role, and removed from all other roles. sp_addrolemember and sp_droprolemember can be used to change role membership in a single role without affecting membership in other roles.
New database users can be added to roles at the same time they are given access to the database with sp_adduser.
Every user is a member of the default role public, if not explicitly added to some other role by sp_addrolemember.
sp_changegroup cannot be executed within a user-defined transaction.
Members of the db_owner or db_securityadmin fixed database roles can execute sp_changegroup for any role in the database.
Role owners can execute sp_changegroup for the roles they own.
This example makes the user Albert a member of the developers role.
EXEC sp_changegroup 'developers', 'Albert'
sp_addrole | sp_dropgroup |
sp_addrolemember | sp_helpgroup |
sp_adduser | System Stored Procedures |