sql 验证测试
时间:2011-03-30 来源:佐伊凡
drop procedure OuterPro
go
create procedure OuterPro
as
begin
declare
@a int,
@b int
begin tran
set @a=1
set @b=2
declare @c int
set @c=@a+@b
print 'c is :' +convert(varchar(2),@c)
exec InnerPro 0
if @@error <>0
begin
print 'before rollback'
rollback tran
print 'OuterPro find InnerPro error'
end
declare @s int
set @s=@a*@b
print 's is :'+convert(varchar(2),@s)
commit tran
end
go
drop Procedure InnerPro
go
create Procedure InnerPro
@c int
as
begin
declare
@d int ,
@e int
set @d=100
set @e=@d/@c
if @@error <>0
print 'innerPro error'
else
print @e
end
go
exec OuterPro
输出结果: c is :3服务器: 消息 8134,级别 16,状态 1,过程 InnerPro,行 10遇到被零除错误。innerPro errors is :2
相关阅读 更多 +










