Microsoft SQL: begin transaction ==> commit/rollback transaction

Is it possible to start an (external) transaction with Microsoft SQL node and then execute some operations (insert/update/delete) and finally execute commit / rollback?

When I try to execute a “begin transaction” I immediately get an error “Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 0, current count = 1.”.
Probably because each node starts its own “internal transaction”.

In case everything is OK I would commit transaction and in case of error rollback transaction.

Do you have any suggestion on how to solve the problem?

yeah the MS SQL node doesnt support multi-statement transactions like that - each operation runs in its own transaction. what you can do is use the Execute Query operation and write your whole transaction as one SQL script:

```sql

BEGIN TRANSACTION;

INSERT INTO table1 VALUES (…);

UPDATE table2 SET …;

IF @@ERROR <> 0

ROLLBACK TRANSACTION;

ELSE

COMMIT TRANSACTION;

```

put all your inserts/updates in a single node with proper error handling. if you need conditional rollback based on n8n logic (not just SQL errors), you could also use the Execute Command node to run sqlcmd with a transaction script, but the single query approach is usually cleaner.