用事务即可:
begin tran t
  update 表1 ....
  update 表2 ...
  update 表3 ...
commit tran t

解决方案 »

  1.   

    没有
    choose
    只有
    case when
     begin tran t
      update 表1 ....
      update 表2 ...
      update 表3 ...
    commit tran t
      

  2.   

    Case A
     when '1' then
        begin tran
        update 表1 
        update 表2
        update 表3
        commit tran
     when '2' then
        (同上)
     when ...
      

  3.   

    对不起,还有一样,这样直接执行三句update,不用判断每一句是否有错吗?
      

  4.   

    那就用事务,case when
     begin tran t
      update 表1 ....
      update 表2 ...
      update 表3 ...
    commit tran t
      

  5.   

    对啊,我知道用事务,比如说现在update 表2时出错,那我怎么知道是在表2出错了呢?而且要在哪里判断呢?
      

  6.   

    不需要你判断,事务出错它会自动回滚(rollback)
      

  7.   

    先谢谢楼上的朋友先,
    但我下面这样写总是提示出错??
    Case  @tno_left 
     WHEN 'M'Then
      begin tran
        update sentwork set w_tno = '1'
      commit tran
    总是提示
    服务器: 消息 156,级别 15,状态 1,过程 pro_Mo,行 25
    在关键字 'Case' 附近有语法错误。
    为什么呢,而且当它自动回滚后我能不能用
     if (@@error <> 0) 判断到出错,然后可以返回值提示用户操作出错呢??