Using WITH (NOLOCK) in T-SQL?

Nolock is T-Sql hint, That used to ignore the locks on table during transactions. It allows retrieving data and did not wait to complete the transaition applied on table. It has some pros can cons

Pros:

  • NoLock provides significant improvements on large table, where upserts commands take time.
  • You can retirve data during the same time while others are performing Insert and update on table.

Cons:

  • Possibility of data that was partially updated or inserted, because you retrieve data during update or insert on table.
  • It often results in very obscure, hard to reproduce bugs and can cause data to get corrupted.

alirazazaidi

Advisory software engineer, Software engineer, Last 4 years focus on Dynamics Ax 2012. MVP and Microsoft Certified trainer for Dynamics AX.