标签:style color sp strong on bs ef nbsp sql
事务==流程控制 确保流程只能成功或者失败,若出现错误会自动回到原点
例:
begin tran
insert into student values(‘111‘,‘王五‘,‘男‘,‘1999-09-09‘,‘95033‘)
if @@ERROR>0
goto tranrollback--直接到tranrollback
insert into course values(‘3-102‘,‘语文‘,‘804‘)
if @@ERROR>0
goto tranrollback
insert into score values(‘111‘,‘3-102‘,98)
if @@ERROR>0
begin
tranrollback:---回滚事务
rollback tran
end
else
commit tran--提交事务
-------------------格式--------------------
begin tran
if @@error>0
goto tranrollback
……
if @@error>0
begin
tranrollback:
rollback tran
end
else
commit tran
标签:style color sp strong on bs ef nbsp sql
原文地址:http://www.cnblogs.com/wleaves/p/4165157.html