2

I have an app that run on many computers and connect to sql server I want to log the machine names of that computers in a table every time they connect how can I do that

I want to know if there is a command like that

"Select @@MachineName"

2 Answers 2

4

It's up to you how you want to log this information, but HOST_NAME() returns the name of the workstation connecting to the server.

Sign up to request clarification or add additional context in comments.

Comments

0

Create linked server : (allowing access to distributed, heterogeneous queries against OLE DB data sources.) using following command :

sp_addlinkedserver [ @server= ] 'server' [ , [ @srvproduct= ] 'product_name' ] [ , [ @provider= ] 'provider_name' ]

 [ , [ @datasrc= ] 'data_source' ] 
 [ , [ @location= ] 'location' ] 
 [ , [ @provstr= ] 'provider_string' ] 
 [ , [ @catalog= ] 'catalog' ] 

Then access is like :

Select * from [server-name].[db-name].dbo.[tablename]

Also, make sure security login you are using on both the servers is same (or atleast exists on other server too).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.