Does anyone have an example of a stored procedure which makes a connection to a remote server?
I have been searching the web and have so far discovered that it might can be done using sp_addlinkedserver
and sp_addlinkedsrvlogin
but I haven't found a good example and I don't understand the documentation that well.
UPDATE:
None of the two first replies help me out, the closest I can get is using this:
EXEC sp_addlinkedserver
@server = 'SiminnSrv',
@provider = 'SQLNCLI',
@catalog = 'devel',
@srvproduct = '',
@provstr = 'DRIVER={SQL Server};SERVER=my.serveradr.com;UID=my_user_name;PWD=my_pass_word;'
That actually makes me connect but when I query a table I get this message:
Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server >connection.