以文本方式查看主题 - 课外天地 李树青 (http://njcie.com/bbs/index.asp) -- 数据库系统原理课件 (http://njcie.com/bbs/list.asp?boardid=19) ---- 关于SQL Server数据库系统中事务处理编程的学习资料 (http://njcie.com/bbs/dispbbs.asp?boardid=19&id=182) |
-- 作者:admin -- 发布时间:2006/5/22 21:00:47 -- 关于SQL Server数据库系统中事务处理编程的学习资料 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编辑过]
|