Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server and connection loss in the middle of a transaction [duplicate]

Possible Duplicate:
What happens to an uncommitted transaction when the connection is closed?

What would happen if lose the connection in the middle of a transaction?

I guess that if the transaction is never committed and could execute again, but... is there a way I can connect and roll it back to a saved point and continue with the things I already have?

Kind regards.

like image 471
vtortola Avatar asked Feb 12 '11 13:02

vtortola


People also ask

What happens if two users try to update a database at the same time?

there will be occasions where two users will both read the same data into memory. User 1 will update the data and write those changes back to the database before user 2 does the same thing. Now you have a concurrency control conflict because user 1 read the data before user 2 wrote it back to the database.

What is SQL concurrency?

Concurrency is the ability of two transactions to use the same data at the same time, and with increased transaction isolation usually comes reduced concurrency.


1 Answers

If you lose the connection in the middle of a transaction you can no longer reenter this transaction from a different connection. If the connection is dropped, SQL Server will rollback any uncommitted transactions automatically. So if this happens, simply reconnect and you will find your database at the same state it was before starting the transaction (assuming of course there aren't other users that might have changed it in between.

like image 160
Darin Dimitrov Avatar answered Nov 14 '22 19:11

Darin Dimitrov