pubilcTreat

sqlservice 结束死锁进程语句

1、悲观锁小实验


declare @sql int
begin tran
select @sql=temp.Amount from temp with(updlock)
waitfor delay '00:00:03'
update temp set Amount=Amount-1 where id=1
update temp set Amount=Amount-1 where id=1
commit tran
select * from temp

 

 

 

--查询死锁进程语句

select    
    request_session_id spid,   
    OBJECT_NAME(resource_associated_entity_id) tableName    
from    
    sys.dm_tran_locks   
where    
    resource_type='OBJECT' 

--结束死锁进程语句

kill spid

posted on   pubilcTreat  阅读(53)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示