是要这个效果? create proc proc_test_test(@intvalue int) as create table tb1(id int check( id in (4,5,6))) create table tb2 (id int) create table tb3(id int) Begin try Begin tran t if(@intvalue>0) Begin insert into tb1 select 1 insert into tb3 select 1 insert into tb2 select 1
End else if (@intvalue<0) Begin
insert into tb1 select 2 insert into tb3 select 1 insert into tb2 select 1 End commit tran t select '成功' select * from tb1 select * from tb2 select * from tb3 drop table tb2 drop table tb1 drop table tb3 end try begin catch select '失败' select * from tb1 select * from tb2 select * from tb3 drop table tb2 drop table tb1 drop table tb3 rollback tran t end catch return
create proc proc_test_test(@intvalue int)
as
create table tb1(id int check( id in (4,5,6)))
create table tb2 (id int)
create table tb3(id int) Begin try
Begin tran t
if(@intvalue>0)
Begin
insert into tb1 select 1
insert into tb3 select 1
insert into tb2 select 1
End
else if (@intvalue<0)
Begin
insert into tb1 select 2
insert into tb3 select 1
insert into tb2 select 1
End
commit tran t
select '成功'
select * from tb1
select * from tb2
select * from tb3
drop table tb2
drop table tb1
drop table tb3
end try
begin catch
select '失败'
select * from tb1
select * from tb2
select * from tb3
drop table tb2
drop table tb1
drop table tb3
rollback tran t
end catch
return