Επεξεργασία

Κοινή χρήση μέσω


sp_dropsrvrolemember (Transact-SQL)

Applies to: SQL Server

Removes a SQL Server login, a Windows user, or Windows group, from a fixed server role.

Important

This feature will be removed in a future version of SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use ALTER SERVER ROLE instead.

Transact-SQL syntax conventions

Syntax

sp_dropsrvrolemember
    [ @loginame = ] N'loginame'
    [ , [ @rolename = ] N'rolename' ]
[ ; ]

Arguments

[ @loginame = ] N'loginame'

The name of a login to remove from the fixed server role. @loginame is sysname, with no default. @loginame must exist.

[ @rolename = ] N'rolename'

The name of a server role. @rolename is sysname, with a default of NULL. @rolename must be one of the following values:

  • sysadmin
  • securityadmin
  • serveradmin
  • setupadmin
  • processadmin
  • diskadmin
  • dbcreator
  • bulkadmin

Return code values

0 (success) or 1 (failure).

Remarks

Only sp_dropsrvrolemember can be used to remove a login from a fixed server role. Use sp_droprolemember to remove a member from a database role.

The sa login can't be removed from any fixed server role.

sp_dropsrvrolemember can't be executed within a user-defined transaction.

Permissions

Requires membership in the sysadmin fixed server role, or both ALTER ANY LOGIN permission on the server, and membership in the role from which the member is being dropped.

Examples

The following example removes the login JackO from the sysadmin fixed server role.

EXEC sp_dropsrvrolemember 'JackO', 'sysadmin';