sp_helprolemember (Transact-SQL)sp_helprolemember (Transact-SQL)

适用对象:是SQL Server 否Azure SQL 数据库 否Azure Synapse Analytics (SQL DW) 否并行数据仓库 APPLIES TO: yesSQL Server noAzure SQL Database noAzure Synapse Analytics (SQL DW) noParallel Data Warehouse

返回有关当前数据库中某个角色的直接成员的信息。Returns information about the direct members of a role in the current database.

主题链接图标 Transact-SQL 语法约定Topic link icon Transact-SQL Syntax Conventions

语法Syntax

  
sp_helprolemember [ [ @rolename = ] 'role' ]  

参数Arguments

[ @rolename = ] ' role '当前数据库中的角色的名称。[ @rolename = ] ' role ' Is the name of a role in the current database. role的值为sysname,默认值为 NULL。role is sysname, with a default of NULL. 角色必须存在于当前数据库中。role must exist in the current database. 如果未指定role ,则返回所有包含当前数据库中的至少一个成员的角色。If role is not specified, then all roles that contain at least one member from the current database are returned.

返回代码值Return Code Values

0(成功)或 1(失败)0 (success) or 1 (failure)

结果集Result Sets

列名称Column name 数据类型Data type 说明Description
DbRoleDbRole sysnamesysname 当前数据库中角色的名称。Name of the role in the current database.
名称MemberName sysnamesysname 数据库角色成员的名称 Name of a member of DbRole.
MemberSIDMemberSID varbinary (85)varbinary(85) 成员名称的安全标识符。Security identifier of MemberName.

备注Remarks

如果数据库包含嵌套角色,则成员名称可能是角色的名称。If the database contains nested roles, MemberName may be the name of a role. sp_helprolemember不显示通过嵌套角色获取的成员身份。sp_helprolemember does not show membership obtained through nested roles. 例如,如果 User1 是 Role1 的成员,而 Role1 是 Role2 的成员,则 EXEC sp_helprolemember 'Role2' 将返回 Role1,而不是 Role1 的成员(在这个示例中为 User1)。For example if User1 is a member of Role1, and Role1 is a member of Role2, EXEC sp_helprolemember 'Role2'; will return Role1, but not the members of Role1 (User1 in this example). 若要返回嵌套成员身份,必须对每个嵌套角色重复执行sp_helprolememberTo return nested memberships, you must execute sp_helprolemember repeatedly for each nested role.

使用sp_helpsrvrolemember显示固定服务器角色的成员。Use sp_helpsrvrolemember to display the members of a fixed server role.

使用IS_ROLEMEMBER (transact-sql)检查指定用户的角色成员身份。Use IS_ROLEMEMBER (Transact-SQL) to check role membership for a specified user.

权限Permissions

要求 公共 角色具有成员身份。Requires membership in the public role.

示例Examples

以下示例显示 Sales 角色的成员。The following example displays the members of the Sales role.

EXEC sp_helprolemember 'Sales';  

另请参阅See Also

安全存储过程 (Transact-sql) Security Stored Procedures (Transact-SQL)
sp_addrolemember (Transact-SQL) sp_addrolemember (Transact-SQL)
sp_droprolemember (Transact-sql) sp_droprolemember (Transact-SQL)
sp_helprole (Transact-sql) sp_helprole (Transact-SQL)
sp_helpsrvrolemember (Transact-sql) sp_helpsrvrolemember (Transact-SQL)
系统存储过程 (Transact-SQL)System Stored Procedures (Transact-SQL)