Skip to content

Latest commit

 

History

History
75 lines (56 loc) · 2.32 KB

File metadata and controls

75 lines (56 loc) · 2.32 KB
title @@REMSERVER (Transact-SQL)
description @@REMSERVER (Transact-SQL)
author MikeRayMSFT
ms.author mikeray
ms.reviewer
ms.date 09/18/2017
ms.prod sql
ms.prod_service sql-database
ms.technology t-sql
ms.topic reference
ms.custom
f1_keywords
@@REMSERVER
@@REMSERVER_TSQL
helpviewer_keywords
logins [SQL Server], remote servers
remote servers [SQL Server], logins
@@REMSERVER function
dev_langs
TSQL

@@REMSERVER (Transact-SQL)

[!INCLUDE SQL Server Azure SQL Managed Instance]

Important

[!INCLUDEssNoteDepFutureAvoid] This function exists for backward compatibility and always returns NULL. 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.

Topic link icon Transact-SQL Syntax Conventions

Syntax

@@REMSERVER  

[!INCLUDEsql-server-tsql-previous-offline-documentation]

Return Types

nvarchar(128)

Remarks

@@REMSERVER enables a stored procedure to check the name of the database server from which the procedure is run.

Examples

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  

See Also

Configuration Functions (Transact-SQL)
Remote Servers