sp_droplinkedsrvlogin (Transact-SQL)sp_droplinkedsrvlogin (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 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. rmtsrvname的值为sysname,无默认值。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. locallogin的值为sysname,无默认值。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_droplinkedsrvloginsp_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)