BEGIN TRAN UPDATE tableA SET HourlyRate = 100 WHERE ConsultantName = 'Raj'Note that the transaction is not committed or rolled back. Since the transaction is open, the lock applied on the row being updated is not released yet. Now, open a second window (Query Window 2) and run the following.
SELECT * FROM tableA
As expected, this will block. The query will try to read a row locked exclusively by another transaction and cannot proceed until the lock is released. Now, let us see what happens under READ UNCOMMITTED isolation level.
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED SELECT * FROM tableA
OR
SELECT * FROM table A WITH(READUNCOMMITTED)
No comments:
Post a Comment