Advertisement
Intermediate SQL Server, Linked Servers

How do you test and verify that a linked server connection is working correctly after it has been configured?

Short answer

You can use the sp_testlinkedserver stored procedure to quickly verify that SQL Server can successfully establish a connection to the linked server, and run a simple test query against a known table on the remote server to confirm that both connectivity and permissions are…

Save SQL Server mock interview
Advertisement
AModel answer
You can use the sp_testlinkedserver stored procedure to quickly verify that SQL Server can successfully establish a connection to the linked server, and run a simple test query against a known table on the remote server to confirm that both connectivity and permissions are properly configured.
EXEC sp_testlinkedserver 'RemoteServer';

SELECT TOP 1 * FROM RemoteServer.SalesDB.dbo.Customers;
Real-world example
A database administrator runs sp_testlinkedserver immediately after configuring a new linked server connection, quickly confirming that the connection details and credentials are all correctly set up before rolling it out to the reporting team.
Likely follow-ups
  • What does it mean if sp_testlinkedserver succeeds but an actual query still fails?
  • How do you troubleshoot a linked server connection that fails this basic test?
Related topics