表被锁住 解决办法

一、应急办法:

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

 

declare @spid int
Set @spid = 81 --锁表进程
declare @sql varchar(1000)
set @sql='kill '+cast(@spid as varchar)
exec(@sql)

彻底解决:

切记 查询时一定要在表后面加上 with(nolock)

重要的事情说3遍:

一定要在表后面加上 with(nolock)

一定要在表后面加上 with(nolock)

一定要在表后面加上 with(nolock)

posted @ 2016-10-26 20:19  谷樵  阅读(655)  评论(0编辑  收藏  举报