出现如下死锁怎么解决,必给分!

xiyuxi2001 2002-05-08 04:29:13
You have a database named SALES. It has a table named INVENTORY.
New sales information to the database updates the inventory table. When the
process execute it gives an error message "Transaction was deadlocked on
resources with another process etc. "

The stored procedure looks like the following.

CREATE PROCEDURE
Update Inventory @ Int ID int
As
Begin
DECLARE @ COUNT int
BEGIN TRANS
SELECT @ Count = Available
From Inventory with (Hold Lock)
WHERE Inventory ID = @ Int ID
IF ( @ Count >0)
UPDATE Inventory SET Available = Count - 1
Where Inventory ID = @ Int ID
COMMIT TRANS
END

A. Change Table hint to UPDATE
B. Remove table hint
C. Change Table hint to Repeatable Read
D. Set Transaction isolation level Serializable
E. Set Transaction isolation level Repeatable Read
...全文
28 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wylyf 2002-05-09
  • 打赏
  • 举报
回复
E
sunnyl00 2002-05-08
  • 打赏
  • 举报
回复
a.
UPDLOCK is best.

34,838

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧