sql server 2008更新是否选择线程安全?
我需要将id为2且statusCode为'Claimed'的表A更新为'booked' 它是线程安全的吗?sql server 2008更新是否选择线程安全?,sql,Sql,我需要将id为2且statusCode为'Claimed'的表A更新为'booked' 它是线程安全的吗? tks您可以通过在子查询中添加和(updlock,holdlock)来提高并发安全性: UPDATE dbo.A SET StatusCode = 'booked' , UpdateDate = GETDATE() OUTPUT INSERTED.id INTO @TableVar WHERE id = ( SELECT TOP 1 wq.id F
tks您可以通过在子查询中添加
和(updlock,holdlock)
来提高并发安全性:
UPDATE dbo.A
SET StatusCode = 'booked'
, UpdateDate = GETDATE()
OUTPUT INSERTED.id INTO @TableVar
WHERE id = (
SELECT TOP 1 wq.id
FROM dbo.A AS wq
WHERE wq.statusCode = 'Claimed' and wq.id = 2
)
一种等效方法是将语句包装为:
这看起来像:
REPEATABLE READ
Specifies that statements cannot read data that has been modified but not yet
committed by other transactions and that no other transactions can modify data
that has been read by the current transaction until the current transaction
completes.
REPEATABLE READ
Specifies that statements cannot read data that has been modified but not yet
committed by other transactions and that no other transactions can modify data
that has been read by the current transaction until the current transaction
completes.
set transaction isolation level repeatable read
start transaction
... your query here ...
commit transaction