Why does the @@TRANCOUNT get incremented by the
SET NOCOUNT ON statement.
I have noticed this problem intermitently and it can cause headaches for concurrency problems, so I just wanted to know if anyone knew why this happens?
e.g.
CREATE PROCEDURE usp_mig_SPName
(
@po_SuccessFailureFlag bit OUTPUT
)
AS
SET NOCOUNT ON
DECLARE @v_InTransaction INT
SET @po_SuccessFailureFlag = 1 --initially set to true
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
--Obtain the number of active transactions for the current connection
SET @v_InTransaction=@@TRANCOUNT
IF @v_InTransaction=0
BEGIN
BEGIN TRANSACTION
--NEVER GETS IN HERE AS THE TRANCOUNT IS INCREMENTED BY THE NOCOUNT STATMENT - Shown clearly in debuging
END
--Release the read locks
IF @v_InTransaction=0
BEGIN
COMMIT TRANSACTION
END
SET NOCOUNT ON statement.
I have noticed this problem intermitently and it can cause headaches for concurrency problems, so I just wanted to know if anyone knew why this happens?
e.g.
CREATE PROCEDURE usp_mig_SPName
(
@po_SuccessFailureFlag bit OUTPUT
)
AS
SET NOCOUNT ON
DECLARE @v_InTransaction INT
SET @po_SuccessFailureFlag = 1 --initially set to true
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
--Obtain the number of active transactions for the current connection
SET @v_InTransaction=@@TRANCOUNT
IF @v_InTransaction=0
BEGIN
BEGIN TRANSACTION
--NEVER GETS IN HERE AS THE TRANCOUNT IS INCREMENTED BY THE NOCOUNT STATMENT - Shown clearly in debuging
END
--Release the read locks
IF @v_InTransaction=0
BEGIN
COMMIT TRANSACTION
END