[FIXED] How to simulate non-repeatable read (SQL Server)

Issue

I read following lines of code on msdn but I am not clear with this and want to simulate.

Nonrepeatable reads occur when a second transaction accesses the same row several times and reads different data every time. This involves multiple reads of the same row. Every time, the information is changed by another transaction.

I didn't understand how second transaction can access the data if row is locked by first transaction under read committed isolation level.


Solution

You can simulate it in this way. Open Microsoft SQL Management Studio. Open 2 tabs and start a transaction in both.

Select data in first window and modify it in second and commit changes.

Then, re run previous select. Data has been changed. This is non repeatable read phenomen. 

enter image description here



Answered By - dani herrera
Answer Checked By - Terry (sql.easybugfix Volunteer)

Related Posts

Post a Comment