Which lock hints should I use (T-SQL)?

后端 未结 5 935
暖寄归人
暖寄归人 2020-12-13 20:45

I want to implement an atomic transaction like the following:

BEGIN TRAN A

SELECT id
FROM Inventory
WITH (???)
WHERE material_id = 25 AND quantity > 10

         


        
5条回答
  •  清歌不尽
    2020-12-13 21:11

    You may actually be better off setting the transaction isolation level rather than using a query hint.

    The following reference from Books Online provides details of each of the different Isolation levels.

    http://msdn.microsoft.com/en-us/library/ms173763.aspx

    Here is good article that explains the various types of locking behaviour in SQL Server and provides examples too.

    http://www.sqlteam.com/article/introduction-to-locking-in-sql-server

提交回复
热议问题