如何才能保障存储过程嵌套调用的原子性
来源:岁月联盟
时间:2008-07-14
DECLARE @TranStarted bit
SET @TranStarted = 0
IF( @@TRANCOUNT = 0 ) -- 用于嵌套
BEGIN
BEGIN TRANSACTION
SET @TranStarted = 1
END
ELSE
SET @TranStarted = 0
.....
IF( @TranStarted = 1 )
BEGIN
SET @TranStarted = 0
COMMIT TRANSACTION
END