ABS
ALL
AND
ANY
AVG
bit
COS
COT
DAY
EXP
GO
IN
LEN
LOG
MAX
MIN
NOT
OR
PI
SET
SIN
STR
SUM
TAN
USE
VAR
Expand Minimize
4 out of 6 rated this helpful - Rate this topic

@@TRANCOUNT

SQL Server 2000

Returns the number of active transactions for the current connection.

Syntax

@@TRANCOUNT

Return Types

integer

Remarks

The BEGIN TRANSACTION statement increments @@TRANCOUNT by 1. ROLLBACK TRANSACTION decrements @@TRANCOUNT to 0, except for ROLLBACK TRANSACTION savepoint_name, which does not affect @@TRANCOUNT. COMMIT TRANSACTION or COMMIT WORK decrement @@TRANCOUNT by 1.

Examples

This example uses @@TRANCOUNT to test for open transactions that should be committed.

BEGIN TRANSACTION
UPDATE authors SET au_lname = upper(au_lname)
WHERE au_lname = 'White'
IF @@ROWCOUNT = 2
   COMMIT TRAN

IF @@TRANCOUNT > 0
BEGIN
   PRINT 'A transaction needs to be rolled back'
   ROLLBACK TRAN
END

See Also

BEGIN TRANSACTION

COMMIT TRANSACTION

ROLLBACK TRANSACTION

System Functions

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.