sp_dropremotelogin (Transact-SQL)sp_dropremotelogin (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 的本地服务器执行远程存储过程。Removes a remote login mapped to a local login used to execute remote stored procedures against the local server running SQL ServerSQL Server.

重要

下一版本的 Microsoft SQL Server 将删除该功能。This feature will be removed in the next version of Microsoft SQL Server. 请不要在新的开发工作中使用该功能,并尽快修改当前还在使用该功能的应用程序。Do not use this feature in new development work, and modify applications that currently use this feature as soon as possible.请改用链接服务器和链接服务器存储过程。Use linked servers and linked-server stored procedures instead.

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

语法Syntax

sp_dropremotelogin [ @remoteserver = ] 'remoteserver'   
     [ , [ @loginame = ] 'login' ]   
     [ , [ @remotename = ] 'remote_name' ]  

参数Arguments

[ @remoteserver = ] 'remoteserver'远程服务器的名称,该远程服务器映射到要删除的远程登录名。[ @remoteserver = ] 'remoteserver' Is the name of the remote server mapped to the remote login that is to be removed. remoteserver的值为sysname,无默认值。remoteserver is sysname, with no default. remoteserver必须已存在。remoteserver must already exist.

[ @loginame = ] 'login'与远程服务器相关联的本地服务器上的可选登录名。[ @loginame = ] 'login' Is the optional login name on the local server that is associated with the remote server. login的值为sysname,默认值为 NULL。login is sysname, with a default of NULL. 如果指定,则必须已经存在登录名login must already exist if specified.

[ @remotename = ] 'remote_name'在从远程服务器登录时映射到登录名的远程登录名的可选名称。[ @remotename = ] 'remote_name' Is the optional name of the remote login that is mapped to login when logging in from the remote server. remote_name的默认值为sysname,默认值为 NULL。remote_name is sysname, with a default of NULL.

返回代码值Return Code Values

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

备注Remarks

如果仅指定了remoteserver ,则将从本地服务器中删除该远程服务器的所有远程登录名。If only remoteserver is specified, all remote logins for that remote server are removed from the local server. 如果还指定了login ,则从本地服务器中删除映射到该特定本地登录名的remoteserver中的所有远程登录名。If login is also specified, all remote logins from remoteserver mapped to that specific local login are removed from the local server. 如果同时指定了remote_name ,则将仅从本地服务器中删除该远程用户的远程登录名。If remote_name is also specified, only the remote login for that remote user from remoteserver is removed from the local server.

若要添加本地服务器用户,请使用sp_addloginTo add local server users, use sp_addlogin. 若要删除本地服务器用户,请使用sp_droploginTo remove local server users, use sp_droplogin.

仅当使用早期版本的 SQL ServerSQL Server 时才需要远程登录。Remote logins are required only when you use earlier versions of SQL ServerSQL Server. SQL ServerSQL Server 7.0 及更高版本改用链接服务器登录。SQL ServerSQL Server version 7.0 and later versions use linked server logins instead. 使用sp_addlinkedsrvloginsp_droplinkedsrvlogin添加和删除链接服务器登录名。Use sp_addlinkedsrvlogin and sp_droplinkedsrvlogin to add and remove linked server logins.

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

权限Permissions

要求具有sysadminsecurityadmin固定服务器角色的成员身份。Requires membership in the sysadmin or securityadmin fixed server roles.

示例Examples

A.A. 删除远程服务器的所有远程登录Dropping all remote logins for a remote server

以下示例删除远程服务器 ACCOUNTS 的条目,因此将删除本地服务器中的登录和远程服务器中远程登录之间的所有映射。The following example removes the entry for the remote server ACCOUNTS, and, therefore, removes all mappings between logins on the local server and remote logins on the remote server.

EXEC sp_dropremotelogin 'ACCOUNTS';  

B.B. 删除登录映射Dropping a login mapping

以下示例删除一个映射的条目,该条目将来自远程服务器 ACCOUNTS 的远程登录映射到本地登录 AlbertThe following example removes the entry for mapping remote logins from the remote server ACCOUNTS to the local login Albert.

EXEC sp_dropremotelogin 'ACCOUNTS', 'Albert';  

C.C. 删除远程用户Dropping a remote user

以下示例删除远程服务器 Chris 上的远程登录 ACCOUNTS。该远程服务器被映射到本地登录 salesmgrThe following example removes the login for the remote login Chris on the remote server ACCOUNTS that was mapped to the local login salesmgr.

EXEC sp_dropremotelogin 'ACCOUNTS', 'salesmgr', 'Chris';  

另请参阅See Also

安全存储过程 (Transact-sql) Security Stored Procedures (Transact-SQL)
sp_addlinkedsrvlogin (Transact-sql) sp_addlinkedsrvlogin (Transact-SQL)
sp_addlogin (Transact-sql) sp_addlogin (Transact-SQL)
sp_addremotelogin (Transact-sql) sp_addremotelogin (Transact-SQL)
sp_addserver (Transact-sql) sp_addserver (Transact-SQL)
sp_droplinkedsrvlogin (Transact-sql) sp_droplinkedsrvlogin (Transact-SQL)
sp_droplogin (Transact-sql) sp_droplogin (Transact-SQL)
sp_helpremotelogin (Transact-sql) sp_helpremotelogin (Transact-SQL)
系统存储过程 (Transact-SQL)System Stored Procedures (Transact-SQL)