In SQL Server, how can I lock a single row in a way similar to Oracle's “SELECT FOR UPDATE WAIT”?

前端 未结 4 1058
一个人的身影
一个人的身影 2020-12-03 01:34

I have a program that connects to an Oracle database and performs operations on it. I now want to adapt that program to also support an SQL Server database.

In the O

4条回答
  •  被撕碎了的回忆
    2020-12-03 02:00

    You're probably looking forwith (updlock, holdlock). This will make a select grab an exclusive lock, which is required for updates, instead of a shared lock. The holdlock hint tells SQL Server to keep the lock until the transaction ends.

    FROM TABLE_ITEM with (updlock, holdlock)
    

提交回复
热议问题