日期:2014-05-16 浏览次数:20445 次
begin transaction m1
insert into dept(id,name_dept) values(1,'部门1')
insert into dept(name_dept) values('部门2') -- id不能为空
insert into dept(id,name_dept) values(3,'部门3')
commit
begin tran
begin try
insert into dept(id,name_dept) values(1,'部门1')insert into dept(name_dept) values('部门2') -- id不能为空
insert into dept(id,name_dept) values(3,'部门3')
commit
end try
begin catch
rollback
end catch
begin try
begin tran
insert into dept(id,name_dept) values(1,'部门1')
insert into dept(name_dept) values('部门2') -- id不能为空
insert into dept(id,name_dept) values(3,'部门3')
commit tran
end try
begin catch
rollback tran
print 'Error Message: '+ERROR_MESSAGE()
print ERROR_LINE()
print Error_Number()
end catch