Skip to content

Latest commit

 

History

History
79 lines (56 loc) · 2.92 KB

sp-helprolemember-transact-sql.md

File metadata and controls

79 lines (56 loc) · 2.92 KB
title description author ms.author ms.reviewer ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs
sp_helprolemember (Transact-SQL)
sp_helprolemember returns information about the direct members of a role in the current database.
markingmyname
maghan
randolphwest
05/15/2024
sql
system-objects
reference
sp_helprolemember_TSQL
sp_helprolemember
sp_helprolemember
TSQL

sp_helprolemember (Transact-SQL)

[!INCLUDE SQL Server]

Returns information about the direct members of a role in the current database.

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

sp_helprolemember [ [ @rolename = ] N'rolename' ]
[ ; ]

Arguments

[ @rolename = ] N'rolename'

The name of a role in the current database. @rolename is sysname, with a default of NULL. @rolename must exist in the current database. If @rolename isn't specified, then all roles that contain at least one member from the current database are returned.

Return code values

0 (success) or 1 (failure).

Result set

Column name Data type Description
DbRole sysname Name of the role in the current database.
MemberName sysname Name of a member of DbRole.
MemberSID varbinary(85) Security identifier of MemberName.

Remarks

If the database contains nested roles, MemberName might be the name of a role. sp_helprolemember doesn't show membership obtained through nested roles. For example if User1 is a member of Role1, and Role1 is a member of Role2, EXEC sp_helprolemember 'Role2'; returns Role1, but not the members of Role1 (User1 in this example). To return nested memberships, you must execute sp_helprolemember repeatedly for each nested role.

Use sp_helpsrvrolemember to display the members of a fixed server role.

Use IS_ROLEMEMBER to check role membership for a specified user.

Permissions

Requires membership in the public role.

Examples

The following example displays the members of the Sales role in the [!INCLUDE sssampledbobject-md] database.

EXEC sp_helprolemember 'Sales';

Related content