日期:2014-05-18  浏览次数:20483 次

请教高手:sql server中事务为什么没作用?
请教高手:sql   server中事务为什么没作用?
代码如下:
begin   transaction  
update   table1
set   name1= 'aaa '   where   id=1     --这个id不存在
if   @@error <> 0
      ROLLBACK   TRANSACTION
update   table2   set   name2= 'bbb '   where   id==2
if   @@error <> 0
      ROLLBACK   TRANSACTION      
commit   transaction

table1中id=1是不存在的,但table2始终能修改,根据事务原理,table2是不能修改的,为什么我这里能修改?百思不得其解!!是设置不对?

------解决方案--------------------
写错了,把and改成or