First time while trying to access the database in different server it will give error. Before accessing it we have to link the database server with the current server, else it will throw exception as below
Could not find server ‘XXXXXXXX’ in sysservers. Execute sp_addlinkedserver to add the server to sysservers.
To Link with current server run the below query
EXEC sp_addlinkedserver @server=’ServerName’
(Or)
EXEC sp_addlinkedsrvlogin Server’, ‘false’, NULL, ‘UserName’, ‘Password’