sp_droplinkedsrvlogin (Transact-SQL)sp_droplinkedsrvlogin (Transact-SQL)

适用对象: yesSQL ServeryesAzure SQL 数据库noAzure SQL 数据仓库no并行数据仓库APPLIES TO: yesSQL Server noAzure SQL Database noAzure SQL Data Warehouse noParallel Data Warehouse

删除运行 SQL ServerSQL Server 的本地服务器上的登录与链接服务器上的登录之间的现有映射。Removes an existing mapping between a login on the local server running SQL ServerSQL Server and a login on the linked server.

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

语法Syntax

  
sp_droplinkedsrvlogin [ @rmtsrvname= ] 'rmtsrvname' ,   
   [ @locallogin= ] 'locallogin'  

参数Arguments

[ @rmtsrvname = ] 'rmtsrvname' 链接服务器的名称,SQL ServerSQL Server应用登录映射。[ @rmtsrvname = ] 'rmtsrvname' Is the name of a linked server that the SQL ServerSQL Server login mapping applies to. rmtsrvnamesysname,无默认值。rmtsrvname is sysname, with no default. rmtsrvname必须已经存在。rmtsrvname must already exist.

[ @locallogin = ] 'locallogin'SQL ServerSQL Server映射到链接服务器的本地服务器上的登录名rmtsrvname[ @locallogin = ] 'locallogin' Is the SQL ServerSQL Server login on the local server that has a mapping to the linked server rmtsrvname. localloginsysname,无默认值。locallogin is sysname, with no default. 映射localloginrmtsrvname必须已经存在。A mapping for locallogin to rmtsrvname must already exist. 如果为 NULL,默认映射创建的sp_addlinkedserver,这将在本地服务器上的所有登录名映射到链接服务器上的登录名被删除。If NULL, the default mapping created by sp_addlinkedserver, which maps all logins on the local server to logins on the linked server, is deleted.

返回代码值Return Code Values

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

备注Remarks

本地服务器的现有映射删除登录名,当使用创建的默认映射sp_addlinkedserver当它连接到链接服务器代表该登录名。When the existing mapping for a login is deleted, the local server uses the default mapping created by sp_addlinkedserver when it connects to the linked server on behalf of that login. 若要更改默认映射,请使用sp_addlinkedsrvloginTo change the default mapping, use sp_addlinkedsrvlogin.

如果默认映射也被删除,只有已显式授予登录名映射到链接服务器的使用的登录名sp_addlinkedsrvlogin,可以访问链接的服务器。If the default mapping is also deleted, only logins that have been explicitly given a login mapping to the linked server, by using sp_addlinkedsrvlogin, can access the linked server.

sp_droplinkedsrvlogin不能从用户定义的事务内执行。sp_droplinkedsrvlogin cannot be executed from within a user-defined transaction.

权限Permissions

要求对服务器拥有 ALTER ANY LOGIN 权限。Requires ALTER ANY LOGIN permission on the server.

示例Examples

A.A. 为现有用户删除登录映射Removing the login mapping for an existing user

以下示例删除从本地服务器到链接服务器 Mary 的登录 Accounts 的映射。The following example removes the mapping for the login Mary from the local server to the linked server Accounts. 因此,登录 Mary 使用默认登录映射。Therefore, login Mary uses the default login mapping.

EXEC sp_droplinkedsrvlogin 'Accounts', 'Mary';  

B.B. 删除默认的登录映射Removing the default login mapping

以下示例删除最初通过在链接服务器 sp_addlinkedserver 上执行 Accounts 而创建的默认登录映射。The following example removes the default login mapping originally created by executing sp_addlinkedserver on the linked server Accounts.

EXEC sp_droplinkedsrvlogin 'Accounts', NULL;  

请参阅See Also

sp_addlinkedserver (Transact-SQL) sp_addlinkedserver (Transact-SQL)
sp_addlinkedsrvlogin (Transact-SQL) sp_addlinkedsrvlogin (Transact-SQL)
系统存储过程 (Transact-SQL)System Stored Procedures (Transact-SQL)