Search code examples
sql-serversql-server-2008sql-server-2012linked-server

List of SQL servers linked to a particular server


If I have multiple SQL Servers and I want to display what are the Linked servers to the actual SQL Server (myServer1) I am connected to, I could execute sp_linkedservers or navigate under Server Objects/Linked Servers and that will show me a list of the servers connected to it.

Now let's say I have access to myServer1 only so I can not execute sp_linkedservers , is there a way to display what are the SQL servers that has myServer1 as a linked server?


Solution

  • your question as i undertsood it: running 'something' on a sql server instance (let's call it A) retrieve the list of other servers/instances that have A as target for a linked server object.

    answer: you can't.

    a linked server is not a persistent connection so the 'target' server has no information about which server has a potential connection referencing it; the target server will notice the existance of the remote server only when a connection is activated (eg a query is run).

    moreover when a connection is activated the target server cannot know if on the other end there is a linked server, an odbc source or any other software object.

    you may scrub the logs looking for remote endpoints but then you are on your own trying to guess if on the remote end there is a linked server or anything else.

    your best bet is a script (powershell, maybe?) that retrieving the list of sql servers produces a list of the linked servers configured on each one.