好象你两个语句倒个顺序就行了吧.update table2 set col2='a' from table1where table.col1='a' and DATEDIFF(second,willBackTime,getdate())>1)col2并没有在下面语句中使用到.update table1 set col1='d' from table1 where col1='a' and DATEDIFF(second,willBackTime,getdate())>1

解决方案 »

  1.   

    begin tran
      update table1 set col1='d' where col1='a' and DATEDIFF(second,willBackTime,getdate())>1
      update table2 set col2='a' from table1 where table1.col1='a' and DATEDIFF(second,table1.willBackTime,getdate())>1) and table1.关联列=table2.关联列
    commit tran
      

  2.   

    感谢,还有第二句我写错了 
    update table2 set col2='a' from table1 where table1.col1='a' and DATEDIFF(second,willBackTime,getdate())>1)
    这句并没有更新TABLE1的指定记录,而是全部都更新了,怎么回事?怎么错的?
    是不是from table1这儿错了?
      

  3.   

    and table1.关联列=table2.关联列
    你少了这个。