事务
BEGIN TRANSACTIONinsert ...
if @@error<>0 
begin
   ROLLBACK TRANSACTION
   goto theend
end
COMMIT TRANSACTIONtheend:

解决方案 »

  1.   

    BEGIN TRANSACTIONinsert ...
    if @@error<>0 
    begin
       ROLLBACK TRANSACTION
       goto theend
    end
    insert ...
    if @@error<>0 
    begin
       ROLLBACK TRANSACTION
       goto theend
    end
    ...COMMIT TRANSACTIONtheend:
      

  2.   

    set xact_abort on 
    begin tran
    --下面录入处理
    insert .....
    insert .....
    --录入处理结束
    commit tran
      

  3.   

    跟楼上的学习一下。那个set xact_abort on 是?
      

  4.   

    set xact_abort on 
    begin tran
    --下面录入处理
    insert .....
    insert .....
    --录入处理结束
    commit tran
    set xact_abort off
      

  5.   

    SET XACT_ABORT
    指定当 Transact-SQL 语句产生运行时错误时,Microsoft&reg; SQL Server&#8482; 是否自动回滚当前事务。
      

  6.   

    是啊,那我不可能每次都把每条insert都写出来吧
    我感觉应该象存储过程能够传递参数似的,传递记录个数