What happens to an uncommitted transaction when the connection is closed?
问题 Are they rolled back immediately? Are they rolled back after some period of time? Are they left in an uncommitted state? Is the behavior the same if connection pooling is used and the connections are simply reset? 回答1: It can stay open while connection pooling applies. Example: command timeout can leave locks and TXN because the client sends as "abort". 2 solutions: Test in the client, literally: IF @@TRANCOUNT <> 0 ROLLBACK TRAN Use SET XACT_ABORT ON to ensured a TXN is cleaned up: Question