sp_addgroup System Stored Procedure

Creates a group in the current database.

Syntax

sp_addgroup grpname

where

grpname
Is the name of the group to add. Group names must follow the rules for identifiers.

Remarks

Groups are used as collective names for granting and revoking permissions.

The sp_addgroup system stored procedure adds an entry for the new group to a database's sysusers table. Each group's uid is a number greater than or equal to 16,384 (except the uid of the public group, which is always 0).

Once a group has been created, you can use the group name as an optional parameter with the sp_adduser system stored procedure, which adds the new user to a group at the same time as it is created. To add an already existing user to a group, use the sp_changegroup system stored procedure.

There is a built-in group, public, in every database. Each user automatically belongs to public and can be added to only other group. You cannot remove a user from the public group.

Example

This example creates an accounting group.

sp_addgroup accounting

Permission

Execute permission defaults to the database owner.

Table Used

sysusers

See Also

GRANT sp_changegroup
REVOKE sp_dropgroup
sp_adduser sp_helpgroup