Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 查询小表时超时_Sql_Tsql_Sql Server 2008_Timeout - Fatal编程技术网

Sql 查询小表时超时

Sql 查询小表时超时,sql,tsql,sql-server-2008,timeout,Sql,Tsql,Sql Server 2008,Timeout,我正在尝试执行一个查询,从列文档(varbinary(max))为null的表中获取所有ID 查询总是超时,我正在对一个5000行的表运行它 select ID from Invoice where Document is null 我正在使用SQLExpress2008R2和SQLManagementStudio。这条路对吗?我错过什么了吗?即使我添加top 1,查询超时有时表也会被锁定。尝试从界面中的选定表中单击 您正在使用什么RDBMS?SQLserver?赛贝斯?或者 当您这样做时,它

我正在尝试执行一个查询,从列
文档(varbinary(max))为null的表中获取所有ID

查询总是超时,我正在对一个5000行的表运行它

select ID from Invoice where Document is null

我正在使用SQLExpress2008R2和SQLManagementStudio。这条路对吗?我错过什么了吗?即使我添加top 1,查询超时有时表也会被锁定。尝试从界面中的选定表中单击

您正在使用什么RDBMS?SQLserver?赛贝斯?或者

当您这样做时,它是否仍然超时:

SELECT TOP 10 ID
from Invoice where Document is null

这样做,以获得只读外观

select ID from Invoice (nolock) where Document is null

我觉得不错。不知道为什么会超时。如果我可以问一下,是哪种RDBMS?我使用的是SQL Server 2008 r2 Express您是从SQL Management Studio还是从客户端代码运行此数据库?请复制/粘贴确切的错误消息,或者屏幕截图。是否有任何查询通过SSMS针对该服务器实例中任何数据库中的任何表工作?Im使用SQL server 2008 r2Express@alenhandrobog:试着像我建议的那样把
放在顶部
子句中,如果您仍然遇到超时,请告诉我们。@alejandrobog:请编辑您的问题,以包括您如何运行此查询。可能包括关于TOP不返回任何内容以确保问题完整性的详细信息。您似乎知道此
nolock
,您知道为什么表会被锁定吗?有什么好的解释吗?我会在大约一小时后,当活动减少时,尝试重新启动服务。我会告诉你结果的。ThanksI重新启动了服务,同样的事情也发生了。您是否能够从DB中的任何表中执行任何select?…还可以尝试使用select TOP 1返回一行…或者使用WHERE子句…如果上述操作都不起作用,那么您可能存在连接或安全问题。
If connecting on localhost Then

    If connecting from Management Studio Then

        Try restarting SQL Server services...could be locks.
        Try restarting machine...could be locks.

    ElseIf connecting from remote app code Then

        Check if SQL Server is setup for remote connections.
        Check connection strings.
        Check seccurity privleges.
        Check log file.

    End If

Else
             Check if SQL Server is setup for remote connections
        Check connection strings.
        Check seccurity privledges.

End If