XACT_STATE
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 FlowSELECT XACT_STATE() AS transaction_state;
Open Microsoft Learn for full syntax, permissions, and details for your version.