sp_dropsrvrolemember (Transact-SQL)sp_dropsrvrolemember (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

从固定服务器角色中删除 SQL ServerSQL Server 登录名或 Windows 用户或组。Removes a SQL ServerSQL Server login or a Windows user or group from a fixed server role.

重要

此功能处于维护模式并且可能会在 Microsoft SQL Server 将来的版本中被删除。This feature is in maintenance mode and may be removed in a future version of Microsoft SQL Server. 请避免在新的开发工作中使用该功能,并着手修改当前还在使用该功能的应用程序。Avoid using this feature in new development work, and plan to modify applications that currently use this feature.请改用ALTER SERVER ROLEUse ALTER SERVER ROLE instead.

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

语法Syntax

sp_dropsrvrolemember [ @loginame = ] 'login' , [ @rolename = ] 'role'  

参数Arguments

[ @loginame = ]"login"[ @loginame = ] 'login'
要从固定服务器角色中删除的登录名。Is the name of a login to remove from the fixed server role. loginsysname为,无默认值。login is sysname, with no default. 登录名必须存在。login must exist.

[ @rolename = ]"role"[ @rolename = ] 'role'
服务器角色的名称。Is the name of a server role. role的值为sysname,默认值为 NULL。role is sysname, with a default of NULL. role必须是下列值之一:role must be one of the following values:

  • sysadminsysadmin

  • securityadminsecurityadmin

  • serveradminserveradmin

  • setupadminsetupadmin

  • processadminprocessadmin

  • diskadmindiskadmin

  • dbcreatordbcreator

  • bulkadminbulkadmin

返回代码值Return Code Values

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

备注Remarks

只能使用 sp_dropsrvrolemember 从固定服务器角色中删除登录。Only sp_dropsrvrolemember can be used to remove a login from a fixed server role. 使用 sp_droprolemember 从数据库角色删除成员。Use sp_droprolemember to remove a member from a database role.

不能从任何固定服务器角色中删除 sa 登录。The sa login cannot be removed from any fixed server role.

不能在用户定义的事务中执行 sp_dropsrvrolemember。sp_dropsrvrolemember cannot be executed within a user-defined transaction.

权限Permissions

需要具有 sysadmin 固定服务器角色中的成员身份,或同时具有对服务器的 ALTER ANY LOGIN 权限以及从中删除成员的角色中的成员身份。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

以下示例从 JackO 固定服务器角色中删除登录 sysadminThe following example removes the login JackO from the sysadmin fixed server role.

EXEC sp_dropsrvrolemember 'JackO', 'sysadmin';  

另请参阅See Also

(Transact-sql)创建服务器角色 CREATE SERVER ROLE (Transact-SQL)
DROP SERVER ROLE (Transact-sql) DROP SERVER ROLE (Transact-SQL)
安全存储过程 (Transact-sql) Security Stored Procedures (Transact-SQL)
sp_addsrvrolemember (Transact-sql) sp_addsrvrolemember (Transact-SQL)
sp_droprolemember (Transact-sql) sp_droprolemember (Transact-SQL)
系统存储过程 (Transact-SQL) System Stored Procedures (Transact-SQL)
安全函数 (Transact-SQL)Security Functions (Transact-SQL)