sql server 用这段语句,3个人一起点就容易死锁,有解决过的没有,如果解决的话,加分给你

SET TRANSACTION ISOLATION LEVEL REPEATABLE READ
BEGIN TRAN

DECLARE @UserCode VARCHAR(20)
SELECT TOP 1 @UserCode=usercode FROM dbo.tb_refUserCode With(RowLock,UpdLock) WHERE usestatus=0 --WHERE UserCode='19642428'

UPDATE dbo.tb_refUserCode SET UseStatus=1 WHERE UserCode=@UserCode

SELECT @UserCode
--waitfor delay '00:00:01'
COMMIT TRAN

改成 这种的试一下,UPDATE dbo.tb_refUserCode SET UseStatus=1 WHERE UserCode=(SELECT TOP 1 usercode FROM dbo.tb_refUserCode With(RowLock,UpdLock) WHERE usestatus=0)