除非包含nolock提示,否则没有锁的表将不会查询 [英] Table without lock won't query unless nolock hint included

查看:72
本文介绍了除非包含nolock提示,否则没有锁的表将不会查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Microsoft SQL Server 2008 R2

Microsoft SQL Server 2008 R2

我有一个当前无法查询的表,但似乎没有锁.

I have a table that currently can not be queried on but seems to not have a lock against it.

不返回:

SELECT * FROM myTable

返回:

SELECT * FROM myTable with (nolock)

插入表中也会失败.

当我运行sp_lock时,在myTable上找不到任何锁的实例.运行按对象列出的资源锁定统计信息"报告时,没有看到myTable的任何锁定.

When I run sp_lock, I don't find any instances of locks on myTable. When I run the "Resource Locking Statistics by Object" report, I don't see any locks for myTable.

还有什么其他可能性可以阻止表格被执行?

What other possibilities could there be that would keep a table from being acted upon?

谢谢.

推荐答案

运行sp_who2并查看所有spid.查看您是否仍然与数据库建立连接,而该连接仍在考虑对表执行插入/更新/删除操作.如果找到它,杀死该spid,您应该可以查询该表.

Run sp_who2 and look at all the spids. See if you still have a connection to the database that is still thinking your performing an insert/update/delete to the table. If you find it, kill the spid and you should be able to query the table.

这篇关于除非包含nolock提示,否则没有锁的表将不会查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆