当前位置:网站首页>Table lock query and unlocking in SQL development part 1
Table lock query and unlocking in SQL development part 1
2022-07-28 15:21:00 【A grain of sand in the sea】
1、 Query table lock process id
select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableName
from sys.dm_tran_locks where resource_type='OBJECT'
2、 According to the process id kill fall
spid To query the process number
declare @spid int
Set @spid = 56
declare @sql varchar(1000)
set @sql='kill '+cast(@spid as varchar)
exec(@sql)
3、 Cursor loop releases table lock
DECLARE @spid VARCHAR(50),
@talbename varchar(100)
DECLARE cursor_name CURSOR FOR -- Define cursors
SELECT request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableName
from sys.dm_tran_locks where resource_type='OBJECT'
OPEN cursor_name -- Open cursor
FETCH NEXT FROM cursor_name INTO @spid,@talbename -- Grab the next row of cursor data
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT ' Table name :'+@talbename+' '+'spid:'+@spid
exec('kill '+@spid)
FETCH NEXT FROM cursor_name INTO @spid,@talbename
END
CLOSE cursor_name -- Close cursor
DEALLOCATE cursor_name -- Release cursor
边栏推荐
- 苹果iPhone手机APP应用图标隐藏怎么找回恢复显示在iPhone苹果手机桌面显示被隐藏的应用APP图标到iPhone苹果手机桌面?
- Is the expansion operator a deep copy or a shallow copy
- Three pain points of software development! How to solve the applet container?
- Shader顶点着色器修改顶点高度的一个思路
- Wonderful frog -- how simple can it be to abandon the float and use the navigation bar set by the elastic box
- Apple iPhone app icon hidden how to retrieve and restore the hidden app icon displayed on the iPhone iPhone desktop to the iPhone iPhone iPhone desktop?
- Instructions for common symbols in kotlin
- day 7/12
- Jogy-61 voltage relay
- 【游戏测试工程师】初识游戏测试—你了解它吗?
猜你喜欢
![[leetcode] 35. Search the insertion position](/img/cd/bd6f5152be098072b3a43a456e4c99.png)
[leetcode] 35. Search the insertion position

全开源免费的客服系统来了

day 7/12

celery 相关

What are the functions to be added in crmeb pro2.2?

Multi merchant mall system with relatively clean code

Daily question (retrospective)

crmeb 标准版window+phpstudy8安装教程(三)

I heard that many merchants of crmeb have added the function of planting grass?

Hjs-de1/2 time relay
随机推荐
Three pain points of software development! How to solve the applet container?
3715. 最少交换次数
4519. 正方形数组的数目
Introduction to mqtt protocol
Customer service system attached to crmeb Standard Edition
JDS-12时间继电器
Establish binary tree + C language code from preorder and middle order
php parse_url绕过白名单
volatile原理
代码比较干净的多商户商城系统
Compilation failure caused by kotlin version upgrade
PMP每日一练 | 考试不迷路-7.28(包含敏捷+多选)
【LeetCode】35、搜索插入位置
The modified network card name of rocky foundation is eth0
What are the CCSP cloud security design principles
每日一题(回溯)
从thinkphp远程代码执行学php反射类
ERROR:bokeh.core.validation.check:E-1001 (BAD_COLUMN_NAME)
Crmeb Standard Edition window+phpstudy8 installation tutorial (II)
边缘技术和小程序容器在智能家居中的应用