Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

sys.server_role_members (Transact-SQL)

Applies To: SQL Server 2014, SQL Server 2016 Preview

Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).

Returns one row for each member of each fixed and user-defined server role.

Applies to: SQL Server (SQL Server 2008 through current version), Azure SQL Data Warehouse Public Preview.

Column name

Data type

Description

role_principal_id

int

Server-Principal ID of the role.

member_principal_id

int

Server-Principal ID of the member.

To add or remove server role membership, use the ALTER SERVER ROLE (Transact-SQL)statement.

Logins can view their own server role membership and can view the principal_id’s of the members of the fixed server roles. To view all server role membership requires the VIEW DEFINITION ON SERVER ROLE permission or membership in the securityadmin fixed server role.

For more information, see Metadata Visibility Configuration.

The following example returns the names and id's of the roles and their members.

SELECT sys.server_role_members.role_principal_id, role.name AS RoleName, 
    sys.server_role_members.member_principal_id, member.name AS MemberName
FROM sys.server_role_members
JOIN sys.server_principals AS role
    ON sys.server_role_members.role_principal_id = role.principal_id
JOIN sys.server_principals AS member
    ON sys.server_role_members.member_principal_id = member.principal_id;

Community Additions

ADD
Show:
© 2015 Microsoft