title: Data deleted with IN clause even if the column doesn't exist
body: <p>So, here is the test query you could play with:</p>
  
  <pre><code>select top 10 * into #tmp FROM A
  delete from #tmp WHERE xxx_id in (select xxx_id FROM B)
  </code></pre>
  
  <p>Actually, all these 10 records are deleted. The question is why are these 10 records deleted?</p>
  
  <p>Note: <code>xxx_id</code> is one column in table <code>A</code> only, it doesn't exist in table <code>B</code>. But the delete statement "works" anyway.</p>
  
  <p>Here's a demonstration of this behaviour: <a href="http://sqlfiddle.com/#!6/963f9/1/1" rel="nofollow">http://sqlfiddle.com/#!6/963f9/1/1</a></p>
  
  <h2>Update</h2>
  
  <p>I found the answer in MSDN: <a href="http://social.msdn.microsoft.com/Forums/en-US/418722dc-a7bf-44c5-a2f6-e8d1cd00dbdc/in-clause-ignores-error-in-subquery-possible-bug?forum=transactsql" rel="nofollow">http://social.msdn.microsoft.com/Forums/en-US/418722dc-a7bf-44c5-a2f6-e8d1cd00dbdc/in-clause-ignores-error-in-subquery-possible-bug?forum=transactsql</a>
  Actually, the MSSQL tried to blind the <code>xxx_id</code> to table <code>B</code> in subquery, if not found, it tries to blind it to table <code>A</code>. So, the query equals:</p>
  
  <pre><code>delete from #tmp WHERE xxx_id = xxx_id
  </code></pre>
  
  <p>and all data was deleted.</p>