事务
BEGIN TRANSACTIONinsert ...
if @@error<>0
begin
ROLLBACK TRANSACTION
goto theend
end
COMMIT TRANSACTIONtheend:
BEGIN TRANSACTIONinsert ...
if @@error<>0
begin
ROLLBACK TRANSACTION
goto theend
end
COMMIT TRANSACTIONtheend:
if @@error<>0
begin
ROLLBACK TRANSACTION
goto theend
end
insert ...
if @@error<>0
begin
ROLLBACK TRANSACTION
goto theend
end
...COMMIT TRANSACTIONtheend:
begin tran
--下面录入处理
insert .....
insert .....
--录入处理结束
commit tran
begin tran
--下面录入处理
insert .....
insert .....
--录入处理结束
commit tran
set xact_abort off
指定当 Transact-SQL 语句产生运行时错误时,Microsoft® SQL Server™ 是否自动回滚当前事务。
我感觉应该象存储过程能够传递参数似的,传递记录个数