当前位置: 代码迷 >> Sql Server >> :sql server中事务为什么没作用
  详细解决方案

:sql server中事务为什么没作用

热度:79   发布时间:2016-04-27 15:53:26.0
请教高手: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
  相关解决方案