SQLServer查询锁表

 1 查看被锁表:
 2 select   request_session_id   spid,OBJECT_NAME(resource_associated_entity_id) tableName   
 3 from   sys.dm_tran_locks where resource_type='OBJECT'
 4 
 5 spid:   锁表进程 
 6 tableName:   被锁表名
 7 
 8 
 9 解锁:
10 declare @spid  int 
11 Set @spid  = 57 --锁表进程
12 declare @sql varchar(1000)
13 set @sql='kill '+cast(@spid  as varchar)
14 exec(@sql) 

 

posted @ 2016-11-30 16:06  小葱拌豆腐~  阅读(4491)  评论(0编辑  收藏  举报