繁体   English   中英

SQL Azure 上的服务器:“执行超时已过期。操作完成前超时时间已过,或者服务器没有响应。”

[英]SQL Server on Azure: "Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding."

我在 Powershell 中本地运行一个循环 bcp 的脚本,将数百个 excel 文件复制到 Azure 上的数据库(我只是将 .network 信息作为 arguments 输入到 bcp)。 在循环的每次执行中,我还进行了一个更新表列的查询。 一开始,它工作正常。 但是大约一分钟后,它会减慢速度停止并最终产生此错误。

47680 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.) Total     : 18250  Average : (2612.60 rows per sec.)
Exception calling "ExecuteReader" with "0" argument(s): "Execution Timeout 
Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding."

我不确定这里发生了什么。 这是超时的查询:

$query = "UPDATE $tableName SET jobID = $dir_id where jobID is NULL;"
$sqlCmd3 = $connection.CreateCommand()
$sqlCmd3.Connection = $connection
$sqlCmd3.CommandText = $query
$sqlCmd3.ExecuteReader() *>$null

您是否尝试过使用“ ExecuteNonQuery ”而不是“ ExecuteReader ”? 执行阅读器打开一个要读取的流,您应通过调用“ EndExecuteReader ”从中关闭该流。 另外,您使用的更新语句是NonQuery语句-只需使用ExecuteNonQuery即可。

雅各布的评论是正确的答案。 在 sql 服务器连接上设置超时是不够的,因为 sql 命令本身也有超时。 如果您有超时问题,请增加两者。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM