The Read uncommitted table hint allows a query to read data that has been modify by other transaction but not yet committed. It means it will return dirty reads which can lead to inconsistent data. This is equivalent to using the SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED statement of session level.
It is similar to nolock table
hint. This hint is similar to NOLOCK. It specifies that the Database Engine not
issue shared locks and not honor exclusive locks. When this option is set, it
is possible to read uncommitted or dirty data; values in the data can be
changed and rows can appear or disappear in the data set before the end of the
transaction.
See the example as below
We have a table
Now in one session we are
updating this table and not yet committed.
|
begin tran update
Employees set Department='ADMIN' where
EmployeeID=5 --commit |
This transaction is not yet committed. Now we are selecting
this table on anther window let’s see
Still this is running.
Now we are using this table hint.
|
select * from
Employees WITH (READUNCOMMITTED) where
EmployeeID=5 |
Here we are getting the un committed data. This is similar
to NOLOCK hint.
No comments:
Post a Comment
If you have any doubt, please let me know.