1、事务提交编程:
begin tran newtran
use students
update stu1 set birthday=birthday-365
update stu2 set age=age+1
commit
2、事务回滚编程:
begin tran newtran
use students
update stu set birthday=birthday-365
update stu set age=age+1
select * from stu
rollback
select * from stu1
select * from stu2
或者:
begin tran newtran
use students
select * from stu
update stu set birthday=birthday-365
select * from stu
rollback
select * from stu
事务的保存点
begin tran newtran
use students
go
select * from stu
delete from stu where number='000001'
select * from stu
save transaction after_delete
select * from grade
update grade set number='000007' where number='000001'
select * from grade
if @@error!=0 or @@rowcount=0
begin
rollback tran after_delete
commit tran
return
end
commit transaction newtran
go
[此贴子已经被作者于2006-12-14 16:49:12编辑过]