SQL0666 - SQL 查询超出指定的时间限制或存储限制
在使用 Odbc 连接字符串调用 DB2 数据库时,我会定期收到此错误消息。我尝试将 DbCommand 对象的 CommandTimeout 设置为多个值,但仍然收到以下错误。
SQL0666 - SQL 查询超出指定的时间限制或存储限制。
有没有什么技巧可以让它停止出错。这很奇怪,因为同一个查询有时会起作用,有时会超时。任何帮助将不胜感激。谢谢!
Periodically, I get this error message while making a call to a DB2 database using the Odbc connection string. I have tried setting the CommandTimeout of the DbCommand object to multiple values, but I still get the following error.
SQL0666 - SQL query exceeds specified time limit or storage limit.
Is there a trick to getting this to stop erroring out. It is very odd because the same query sometimes will work and sometimes will timeout. Any help would be appreciated. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我设置 DbCommand.CommandTimeout= 0 这修复了超时错误
I set the DbCommand.CommandTimeout= 0 and this fixed the timeout error
Kite 的答案是正确的,但是,在从 SQL Server 集成服务 (SSIS) 项目中搜索对同一错误消息的修复时,我想分享我在找到此问题和答案后的观察/经验。
今天早些时候,我的一个 SSIS 包开始在其中一个步骤中收到此错误。经过一番研究后,我发现我的包在通过 ODBC 连接到 iSeries 数据库的
DataReader Source
对象上失败。我不确定这是 ODBC 错误还是 iSeries/ODBC DB 驱动程序中的错误,但错误消息完全相同。对我来说,真正奇怪的是我可以浏览 MS Access 中链接表中的数据,该表通过相同的 ODBC 连接进行连接,并且我还可以对同一数据集运行
MAKE TABLE
操作Access 内没有任何问题。搜索错误消息后,我发现了这个 Q &答:此技巧也适用于 SSIS 包。要在 SSIS 中修复此问题,您需要在 Microsoft BIDS 设计器中打开包。接下来,打开关联的
数据流任务
,然后选择遇到超时的DataReader Source
对象。您的
DataReader Source
对象有一个也名为CommandTimeout
的属性。将其设置为0
(而不是默认的30
)应该可以解决该问题。确认超时是问题所在后,我将超时设置为 60 并重新执行该步骤。一分钟的超时解决了问题。值得注意的是,您可能会将所有
DataReader Source
对象上的CommandTimeout
值更新为0
。不建议这样做。相反,保留超时并将限制增加到相当慷慨的值。像我一样,将它们加倍,或者给出更慷慨的 5-10 分钟超时值。超时属性的存在是有原因的。您可以为您的应用程序提供足够的超时时间,但如果应用程序根本没有超时,您的应用程序可能会挂起,因为您的数据库引擎内部存在问题,导致该步骤永远无法完成执行!这可能不太可能,但并非不可能。
确保安全并适当调整超时时间。
Kite's answer is the correct, however, I wanted to share my observation/experience after finding this Question and Answer while searching for a fix to this same error message from within a SQL Server Integrated Services (SSIS) project.
Earlier today one of my SSIS Packages started to receive this error on one of it's steps. After a bit of research I found that my package was failing on a
DataReader Source
object that connects to an iSeries database through ODBC. I'm not sure if this is an ODBC error, or an error within the iSeries/ODBC DB drivers, but the error message was exactly the same.For me, the really odd thing was that I could browse the data from in a linked table in MS Access which connects through the same ODBC connection and I could also run a
MAKE TABLE
operation off of the same dataset within Access without any trouble. After searching for the error message, I found this Q & A. This tip also works for SSIS packages as well.To fix this within SSIS you need to open your package in the Microsoft BIDS designer. Next, open the associated
Data Flow Task
and then select theDataReader Source
object that is experiencing the timeout.Your
DataReader Source
object has a property that is also namedCommandTimeout
. Setting it to0
(rather than the defaulted30
) should fix the problem. After verifying that the timeout was the issue, I set the timeout to60
and re-executed the step. The one minute timeout fixed the problem.It's worth noting that it may be tempting to update your
CommandTimeout
values on all of yourDataReader Source
objects to0
. This isn't recommended. Instead, keep the timeouts and increase the limit to a rather generous value. Double them, as I did, or give an even more generous 5-10 minute timeout value.Timeout properties exist for a reason. You can give your application generous timeouts but if the application doesn't timeout at all, your application may hang on the off-chance that there is a problem from within your Database engine that causes the step to never finish executing! This may be unlikely but isn't impossible.
Be safe and adjust your timeouts appropriately.
对于我这种方式有效,请在执行之前编辑 cmd OdbcCommand......
For my this way works, edit cmd OdbcCommand before execute.....