r/SQLServer • u/sd2528 • Sep 26 '25
Solved Using Transactions/commit/rollback on an ODBC connection with multiple open editable queries
We've been trying to do this, but it seems an ODBC connection with multiple open editable queries, that do do either a commit or rollback, invalidates the cursors on other queries.
I've definitely done this in the past with other database products (Sybase and SAP), but I'm guessing I'm setting something up wrong or not turning on a flag somewhere.
I've tested opening a separate ODBC connection for each individual query, and that works, but that isn't an ideal solution.
My investigating with google and AI leads me to thinking this can be done, but that it is a property on the ODBC driver... but that might not be accurate. Does anyone have any experience with this that you can point me in the right direction?
3
u/stedun 2 Sep 26 '25
You are probably looking for enabling MARS with SQL Server ODBC driver that is multiple active result sets. In the driver, you have to set it to yes or true.
3
u/dbrownems Microsoft Employee Sep 26 '25
In SQL Server a connection is associated with exactly one session, and a rollback affects the whole session. If you want independent transactions, you must have multiple sessions, and thus multiple connections.
1
u/KBradl Sep 26 '25
What do you mean invalidates? Do they return nothing?
One issue I found with transactions is if you do an update to and query the same object in the same connection, it timeouts due to record locking. Not sure if this is your issue.