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

xiyuxi2001 xiyuxi2001 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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
...全文
评论 2
收藏 已收藏
分享
返回顶部
xiyuxi2001
MS-SQL Server 34,876 成员 254,635 内容