sp_helpgroup (Transact-SQL)

Reports information about a role, or all roles, in the current database.

Important

sp_helpgroup provides compatibility with earlier versions of SQL Server. This feature will be removed in the next version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use the sys.database_principals catalog view instead.

Topic link iconTransact-SQL Syntax Conventions

Syntax

sp_helpgroup [ [ @grpname = ] 'role' ]

Arguments

  • [ @grpname = ] 'role'
    Is the name of a role. role must exist in the current database. role is sysname, with a default of NULL. If role is specified, information about the name of the role and the members of the role is returned; otherwise, information about all the roles in the current database is returned.

Return Code Values

0 (success) or 1 (failure)

Result Sets

If role is not specified, the following information will be returned for all roles.

Column name Data type Description

group_name

sysname

Name of the role in the current database.

group_id

smallint

Role ID for the role in the current database.

If role is specified, the following information will be returned.

Column name Data type Description

group_name

sysname

Name of the role in the current database.

group_id

smallint

Role ID for the role in the current database.

users_in_group

sysname

Member of the role in the current database.

userid

smallint

User ID for the member of the role.

Remarks

To view the permissions associated with a role, use sp_helprotect.

Permissions

Requires membership in the public role.

Examples

A. Returning information about a single role

The following query returns information about the SammamishShippers role.

EXEC sp_helpgroup 'SammamishShippers'

B. Returning information about all roles

The following example returns information about all roles in the current database.

EXEC sp_helpgroup

See Also

Reference

Database Engine Stored Procedures (Transact-SQL)
sys.database_principals (Transact-SQL)
sp_helprotect (Transact-SQL)
sp_helprole (Transact-SQL)
sp_helpuser (Transact-SQL)
System Stored Procedures (Transact-SQL)

Help and Information

Getting SQL Server 2005 Assistance