Finding server name on remote server

  • Hi, could somebody please let me know how I can find the server name on a remote server using a linked server query?

    I've tried running various functions but they pull the result back from the local host, not the remote server I'm trying to run the query on.  Alternatively is there a system table that holds the server name in.

    Thanks very much, Simon

  • You have to write a SP on the remote server that does this

    select host_name()

     

    Then you have to execute that SP from the linking server.


    N 56°04'39.16"
    E 12°55'05.25"

  • If you have a linked server, the properties of the link are in system table master..sysservers.

    SELECT datasource

    FROM master..sysservers

    WHERE srvname = 'YourLinkAlias'

  • Thank you both for your replies. 

    I had looked at sysservers but I want to run the same query on all servers from one server that has all the 'linked' ones configured.  I also need to join this against user tables and therefore can't hardcode aliases.

    I had thought of creating a table on each DB with the servername in it, I guess similar to the host_name () option.

    Thanks very much for your response

     

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply