SQL Flow Field Guide

XACT_STATE

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

reads transaction state

What changes

Input
transaction state
Output or change
1 committable, 0 none, -1 uncommittable
Return type
smallint

Syntax at a glance

XACT_STATE()

Work example

Decide whether a transaction can commit or must be rolled back after an error.

Check XACT_STATE in CATCH and roll back an uncommittable transaction before returning.

Check your work A value of -1 means the active transaction cannot commit, while 0 means no transaction is active.

Practice SQL

Open in SQL Flow
SELECT XACT_STATE() AS transaction_state;

Open Microsoft Learn for full syntax, permissions, and details for your version.