title: Delete Join Statement
body: <p>I am trying to use Delete statement in my Stored Procedure but it is giving me an error saying,</p>
  
  <p>Invalid object name 'BRWSQLDC'.</p>
  
  <p>and below is my Delete Statement:</p>
  
  <pre><code>set @Query = 'DELETE FROM ' + @DestLinkServer + ' FROM .HL2_61.dbo.ArtPDF AP JOIN .HL2_61.dbo.Article A on A.ArticleID = AP.ArticleID ' + ' WHERE ArticleKey = ' + CONVERT(VARCHAR, @Id)
  </code></pre>
  
  <p>When I execute it as below</p>
  
  <pre><code>DELETE FROM BRWSQLDC FROM .HL2_61.dbo.ArticlePDF AP JOIN .HL2_61.dbo.Article A on A.ArticleID = AP.ArticleID  WHERE ArticleKey = -1591276581
  </code></pre>
  
  <blockquote>
    <p>Error is: Invalid object name 'BRWSQLDC'.</p>
  </blockquote>
  
  <p>And if I try to execute the code as below:</p>
  
  <pre><code>'DELETE FROM ' + @DestLinkServer + ' .HL2_61.dbo.ArticlePDF AP JOIN .HL2_61.dbo.Article A on A.ArticleID = AP.ArticleID ' + ' WHERE ArticleKey = ' + CONVERT(VARCHAR, @Id)
  </code></pre>
  
  <p>when passing the values,</p>
  
  <pre><code>DELETE FROM BRWSQLDC .HL2_61.dbo.ArticlePDF AP JOIN .HL2_61.dbo.Article A on A.ArticleID = AP.ArticleID  WHERE ArticleKey = -1591276581
  </code></pre>
  
  <p>error I am getting is: </p>
  
  <blockquote>
    <p>Incorrect syntax near 'AP'.</p>
  </blockquote>
  
  <p>Please help me how to join 2 tables in a delete and then delete that in the server if it exists.</p>