事务处理。begin tran
   insert into t1...
   insert into t2...
   .....
commit tran

解决方案 »

  1.   

    SET XACT_ABORT on ----设置
    gocreate table #Table1 (a tinyint)
    go
    begin tran
      insert #table1 values(1)              ----成功
      insert #table1 values(1000)           ----这句将报错
    commit tran
    go
    select * from #table1 
    go
    drop table #table1
      

  2.   

    create table Table1 (a int)
    go
    begin tran
      insert table1 values(1)               ----这句是对的
      insert table1 values('aaa')           ----这句由于类型不一样将报错
    commit transelect * from table1         ------结果是两句都没插入!应为他们是一个事务
      

  3.   

    TO pengdali :SET XACT_ABORT on 对于显示提交事务是必须的吗