If I am reading your question correctly, you want to query each server to get the connection string for how to connect to that server.
That is not information you find in the server itself, but it is up to the caller how to refer to the server in the connection string. And there are some options:
- By server name only.
- By FQDN.
- By IP-address.
- By a DNS-alias. That is, while the name of the server is Charles, there is an alias somewhere mapping James to Charles, so that James works as well.
- The same above, except that the alias is set up in /etc/hosts locally on the server, or in the registry (through SQL Server Configuration Manager, for instance.)
And if server in question is a named instance, the instance may be referred to by name or port number. Or by an alias.
A better approach may be to set up logon triggers that logs the information from the eventdata() function in a table. Of particular interest is the client_net_address attribute, which informs you from which machine the connection was made.
But be careful! Incorrectly implemented logon trigger can cause an outage when no one can login.