@@REMSERVER (Transact-SQL)
Applies to:
SQL Server
Azure SQL Managed Instance
Important
This feature will be removed in a future version of SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. 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 SQL Server database server as it appears in the login record.
Transact-SQL syntax conventions
Syntax
@@REMSERVER
Note
To view Transact-SQL syntax for SQL Server 2014 (12.x) and earlier versions, see Previous versions 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;
Here is the result set.
---------------
LONDON2
See Also
Feedback
https://aka.ms/ContentUserFeedback.
Kommer snart: I hele 2024 udfaser vi GitHub-problemer som feedbackmekanisme for indhold og erstatter det med et nyt feedbacksystem. Du kan få flere oplysninger under:Indsend og få vist feedback om