0

I'm developing a .NET application that interacts with a database. In a method I begin a SQL Transaction and modify some values in table1, after I'm done with the changes (but still haven't committed the transaction) I launch a Threading.Thread to go update values in table2 using data from table1.

Will this thread read the modified values? Or will it load the data as it was before transaction was begun?

2 Answers 2

2

It depends on if the second thread is using the same connection/session in which the transaction was started. If it is, then it can see the changes made so far during that transaction. If it is a different connection, it will be blind to those changes until they are committed.

2

Using the RepeatableRead or ReadUncommitted transaction isolation levels for the transaction in the second thread will allow you to read the uncommitted data from table1.

More info on transaction isolation levels:

IsolationLevel Enumeration

Set Transaction Isolation Level (Transact-SQL)

Different is the question how will you ensure that the data is written to table1 before reading it and updating table2, but this depends on your .NET application implementation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.