declare user_cur cursor for
SELECT request_session_id spid,OBJECT_NAME(resource_associated_entity_id)tableName FROM sys.dm_tran_locks WHERE resource_type='OBJECT '
--打开游标
open user_cur
while @@fetch_status=0
begin
--读取游标
fetch next from user_cur into @spid,@tableName
print @spid
set @str= 'KILL '+convert(varchar(20),@spid)
exec(@str)
--print @Login
end
close user_cur
--摧毁游标
deallocate user_cur