Bob Duffy on 22 Sep 2023 14:38:51
The code below behaves differently on Fabric DW v Synapse SqlPool in that an error does not auto rollback the transaction and @@TRANCOUNT =1 instead of @@TRANCOUNT=0 as expected,
The impact here is if we drop a table and accidently query it (race condition), we end up with transaction leaks with no commit or rollback.
BEGIN TRAN;
select * from table_that_doesnt_exist
IF @@TRANCOUNT > 1
COMMIT TRAN
The code below does work as expected, so the issue is only reproducible when we get a compile error as opposed to a syntax or other error
BEGIN TRAN;
select 1/0
IF @@TRANCOUNT > 1
COMMIT TRAN
In this case the @@TRANCOUNT is 1 in Fabric, but 0 in all other SQL Editions
Kevin Conan (administrator)
Bob, could you please open a support ticket for this? I see the same behavior in both Fabric and SQL 2022, so we need to dive deeper with you to understand the challenge that you're bringing up.