| title | @@REMSERVER (Transact-SQL) | Microsoft Docs | |||
|---|---|---|---|---|
| ms.custom | ||||
| ms.date | 09/18/2017 | |||
| ms.prod | sql | |||
| ms.prod_service | sql-database | |||
| ms.service | ||||
| ms.component | t-sql|functions | |||
| ms.reviewer | ||||
| ms.suite | sql | |||
| ms.technology |
|
|||
| ms.tgt_pltfrm | ||||
| ms.topic | language-reference | |||
| f1_keywords |
|
|||
| dev_langs |
|
|||
| helpviewer_keywords |
|
|||
| ms.assetid | 0bb451a9-3866-4064-963d-b74a2f864049 | |||
| caps.latest.revision | 23 | |||
| author | edmacauley | |||
| ms.author | edmaca | |||
| manager | craigg | |||
| ms.workload | On Demand |
[!INCLUDEtsql-appliesto-ss2008-xxxx-xxxx-xxx-md]
Important
[!INCLUDEssNoteDepNextDontUse] Use linked servers and linked server stored procedures instead.
Returns the name of the remote [!INCLUDEssNoVersion] database server as it appears in the login record.
Transact-SQL Syntax Conventions
@@REMSERVER
nvarchar(128)
@@REMSERVER enables a stored procedure to check the name of the database server from which the procedure is run.
The following example creates the procedure usp_CheckServer that returns the name of the remote server.
CREATE PROCEDURE usp_CheckServer
AS
SELECT @@REMSERVER;
The following stored procedure is created on the local server SEATTLE1. The user logs on to a remote server, LONDON2, and runs usp_CheckServer.
EXEC SEATTLE1...usp_CheckServer;
[!INCLUDEssResult]
---------------
LONDON2