title: Connect to remote server in T-SQL (SQL server 2008)
body: <p>Does anyone have an example of a stored procedure which makes a connection to a remote server?</p>
  <p>I have been searching the web and have so far discovered that it might can be done using <code>sp_addlinkedserver</code> and <code>sp_addlinkedsrvlogin</code> but I haven't found a good example and I don't understand the documentation that well.</p>
  <h3>UPDATE:</h3>
  <p>None of the two first replies help me out, the closest I can get is using this:</p>
  <pre><code>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;'
  </code></pre>
  <p>That actually makes me connect but when I query a table I get this message:</p>
  <blockquote>
  <p>Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server &gt;connection.</p>
  </blockquote>