To Read the Not committed data in SQL server we can use the NOLOCK option.
Sometimes if you are trying to read the data from the table you can notice that the query is executing for a long time, because the table is locked by other transaction.
Once the transaction is completed the lock will be released from the table then you can the see the data in the table.
To avoid this we can use the NOLOCK option to read the uncommitted data in the table.Following example explain how to use the NOLOCK option in SQL query.
Example
Select * from StudentDetail (NOLOCK)
You can also use the With Keyword as shown below.
Select * from StudentDetail WITH (NOLOCK)
If you want to read the uncommitted data you can go with this option else you need to wait for the transaction to commit.
No comments:
Post a Comment