title: Stored Procedure: Linked server login failure
body: <p>I'm getting "Msg 18456, Level 14, State 1, Line 1
  Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'." from when trying to execute the code below. I've change all of the critical information, but you should get the idea.</p>
  
  <p>Are some of my parameter incorrect? The local sql admin username is correct and the remote username and password is correct, but it still keeps telling me that the login failed. Any ideas?</p>
  
  <p>Overall, are there other changes I need to make? Can I insert data this way?</p>
  
  <p>Both DBs are sql server 2005. One is local, one is offsite and accessible via a secure vpn tunnel. I have no trouble acessing the offsite DB using SSMS using the username and password i've been provided(those i've been using in my SP).</p>
  
  <pre><code>-- establish the linked server and login.   
  EXEC sp_addlinkedserver   @server=SERVER1,@srvproduct='',@provider='SQLNCLI', @datasrc='SERVER IP ADDRESS'
  
  EXEC sp_addlinkedsrvlogin SERVER1, 'false', 'LOCAL SQL ADMIN USERNAME', 'REMOTE USERNAME', 'REMOTE PASSWORD'
  
  insert into [SERVER1].DATABASE.dbo.INSERTTABLE(....) select fields from localtable
  
  -- drop the linked server and login
  EXEC Sp_DropServer SERVER1, 'droplogins'
  </code></pre>