sql server 在存储过程中使用事物

来源:互联网 发布:seo牛人 编辑:程序博客网 时间:2024/06/05 17:50
===============================================在存储过程中使用事物=================================================================
use db_sql2008 
if exists(select name from sysobjects where name='EventProc1' and type='P') 
drop procedure EventProc1 
go
create procedure EventProc1 
as
declare @truc int
select @truc=@@TRANCOUNT 
if @truc=0 
begin tran p1
else
save tran p1
if(@truc=2)
begin
rollback tran p1
return 25
end
if (@truc=0)
commit tran p1
return 0
阅读全文
0 0
原创粉丝点击