@@REMSERVER (Transact-SQL)@@REMSERVER (Transact-SQL)
适用于:Applies to: SQL ServerSQL Server(所有支持的版本)
SQL ServerSQL Server (all supported versions)
SQL ServerSQL Server(所有支持的版本)
SQL ServerSQL Server (all supported versions)
重要
后续版本的 Microsoft SQL Server 将删除该功能。This feature will 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. 请改用链接服务器和链接服务器存储过程。Use linked servers and linked server stored procedures instead.
返回远程 SQL ServerSQL Server 数据库服务器在登录记录中显示的名称。Returns the name of the remote SQL ServerSQL Server database server as it appears in the login record.
Transact-SQL 语法约定
Transact-SQL Syntax Conventions
语法Syntax
@@REMSERVER
备注
若要查看 SQL Server 2014 及更早版本的 Transact-SQL 语法,请参阅早期版本文档。To view Transact-SQL syntax for SQL Server 2014 and earlier, see Previous versions documentation.
返回类型Return Types
nvarchar(128)nvarchar(128)
注解Remarks
使用 @@REMSERVER,存储过程可以检查其运行所在的数据库服务器的名称。@@REMSERVER enables a stored procedure to check the name of the database server from which the procedure is run.
示例Examples
以下示例将创建返回远程服务器名称的过程 usp_CheckServer
。The following example creates the procedure usp_CheckServer
that returns the name of the remote server.
CREATE PROCEDURE usp_CheckServer
AS
SELECT @@REMSERVER;
以下存储过程是在本地服务器 SEATTLE1
上创建的。The following stored procedure is created on the local server SEATTLE1
. 用户登录到远程服务器 LONDON2
上,然后运行 usp_CheckServer
。The user logs on to a remote server, LONDON2
, and runs usp_CheckServer
.
EXEC SEATTLE1...usp_CheckServer;
下面是结果集:Here is the result set.
---------------
LONDON2
另请参阅See Also
配置函数 (Transact-SQL) Configuration Functions (Transact-SQL)
远程服务器Remote Servers