一个死锁问题
存储过程用了事务,代码如下:
begin tran
update t1 set Status = 1,a2 = getdate() where nID = @nID
select @UserPRI = isnull(UsePRI,3) from t1 where nID = @nID
if(@UserPRI = 1)
BEGIN
update t2 set c2= @nID where c1 = @c1
END
<ridlock fileid="1" pageid="153417" dbid="13" objectname="" id="lock17136a400" mode="X" associatedObjectId="72057594043957248">
<owner-list>
<owner id="process584e508" mode="X" />
</owner-list>
<waiter-list>
<waiter id="process5844508" mode="U" requestType="wait" />
</waiter-list>
</ridlock>
<ridlock fileid="1" pageid="153040" dbid="13" objectname="" id="lock44b39a300" mode="X" associatedObjectId="72057594043957248">
<owner-list>
<owner id="process5844508" mode="X" />
</owner-list>
<waiter-list>
<waiter id="process584e508" mode="S" requestType="wait" />
</waiter-list>
</ridlock>
</resource-list>
begin tran
select * into #t from t1 where 1=2
update t1
set Status=1,
a2=getdate()
output inserted.* into #t
where nID=@nID
select @UserPRI=isnull(UsePRI,3)
from #t
if(@UserPRI = 1)
BEGIN
update t2 set c2= @nID where c1 = @c1
END
...