簡體   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