code_junkie

Which lock hints should I use (T-SQL)

Nov 14th, 2011
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. BEGIN TRAN A
  2.  
  3. SELECT id
  4. FROM Inventory
  5. WITH (???)
  6. WHERE material_id = 25 AND quantity > 10
  7.  
  8. /*
  9. Process some things using the inventory record and
  10. eventually write some updates that are dependent on the fact that
  11. that specific inventory record had sufficient quantity (greater than 10).
  12. */
  13.  
  14. COMMIT TRAN A
  15.  
  16. SELECT id
  17. FROM Inventory (UPDLOCK)
  18. WHERE material_id = 25 AND quantity > 10;
  19.  
  20. http://www.devx.com/tips/Tip/13134
  21.  
  22. SELECT id
  23. FROM Inventory
  24. WHERE material_id = 25 AND quantity > 10
  25. FOR UPDATE;
Add Comment
Please, Sign In to add comment