比如: create proc example
      as ...
      update a .....
      update b......1,我想问问存储过程中如果有多条句,那么每条语句之间update语如何来判断是否全部1执行成功?
2,如果存储过程执行结束,在开发环境中如何判断调用的存储过程执行成功了??在开发环境中调用
exec procduce  example
...如何判断调用成功?

解决方案 »

  1.   

    可以在存储过程里面加入察看标记!
    create proc example
          as ...
          update a .....
          update b......
    select * from a
    select * from b
      

  2.   

    create proc example
          as ...
          update a .....
          update b......
      if @@error<>0
    print 'ok'
    else 
    print 'no'
      

  3.   

    create proc test
     as 
    begin tran test1
    select * from  table1
    if(@@rowcount>0)
    begin
    goto Err --失败
    end
    insert into table2(id) values('1')
    if(@@error>0 or @@rowcount=0)
     begin
      goto Err --失败
     end
    commit tran  test1
    return 1  --成功返回1
    :Err
    rollback   tran  test1