这个不是bug吧,delete a where id in (select id from b) 这个你用到子查询,如果b表中没有id列,那么查询的是a表的id列,自然会把a表中所有的数据删掉。看看查询计划就知道了

解决方案 »

  1.   

    我认为既然b表没有id列,就应该提示出错,即使不提示出错,也应该不删除任何记录,因为子查询的范围是空值。
    如果修改一下delete a where id in (select id1 from b) ,这个语句是会提示没有字段id1。
      

  2.   

    终于等到Microsoft的回复Hi,
    The behavior you are seeing is by design. In the correlated subquery, if you do not qualify column references we will first try to bind the columns to the FROM clause in the subquery and if that fails we will try to bind to the FROM clause in the outer query. This is also according to ANSI SQL specifications and works pretty much the same in other database systems too. You have to use table aliases to write queries that doesn't result in such ambiguous behavior. See the KB article below for more details.http://support.microsoft.com/kb/298674--
    Umachandar, SQL Programmability Team 由 Microsoft 在 2009/5/8 10:54 发送学习