title: Cannot find 'server\db' in sys.servers
body: <p>My SQL Server job is supposed to create a linked server and query it. However there seems to be an issue with the name and I can not figure out where. I tried googling and it seems that linked server is made, but the query "misreads" the name. Please tell why this happens or where am I messing up.</p>
  
  <pre><code>DECLARE @tmp_key VARCHAR(14)
   DECLARE @db cursor
   DECLARE @sql NVARCHAR(MAX)
  
  exec sys.sp_addlinkedserver '[server\db]'
  
  SET @db = CURSOR FOR  
  </code></pre>
  
  <p>Here is the error part:</p>
  
  <pre><code>SELECT RIGHT('000'+CAST([CONro]AS VARCHAR(4)),4) 
  FROM [server\db].[TKYHT].[dbo].COMPANY 
  WHERE [CONro] NOT IN ('1','95','104','105','183','213','275','603','620','802','998','1001','1002',
  '1105','1112','1113','1122','1179','1183','1189','1458','1508','1516','1575','1599','1602',
  '1691','1841','2184','3073','3074','3980','3989','6158','6164','9990','9999') 
  ORDER BY [CONro] ASC
  </code></pre>
  
  <p>The error is;</p>
  
  <blockquote>
    <p>Cannot find 'server\db' in sys.servers , Verify that the correct
    server name was specified. If necessary, execute the stored procedure
    sp_addlinkedserver to add the server to sys.servers. [SQLSTATE 42000]
    (Error 7202). The step failed.</p>
  </blockquote>
  
  <p>Some ok code here:</p>
  
  <pre><code>exec sys.sp_dropserver '[server\db]'
  </code></pre>