SQL Flow Field Guide

BEGIN TRANSACTION

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

starts a local transaction

What changes

Input
none
Output or change
@@TRANCOUNT + 1

Syntax at a glance

BEGIN { TRAN | TRANSACTION } [ { transaction_name | @tran_name_variable } [ WITH MARK [ 'description' ] ] ] [ ; ]

Work example

Several related changes must succeed or roll back as one unit.

Keep the transaction short. Define the commit point, error path, and expected lock duration before adding work.

Check your work The first read shows one open transaction. The second shows zero.

Practice SQL

Open in SQL Flow
BEGIN TRANSACTION;
SELECT @@TRANCOUNT AS OpenCount;
ROLLBACK TRANSACTION;
SELECT @@TRANCOUNT AS OpenCount;

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