这个 vbs 脚本已经每晚运行几年了。现在我收到超时错误。它会在几秒钟内超时。
DataSource = "127.0.0.1"
DatabaseName = "xxxxxxxx"
DBUser = "xx"
DBPassword = "xxxxxx"
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'This is the original SQL statement
SQL = "SELECT top 1000000 CONVERT(VARCHAR(10),TimeStamp,101) + ' ' + CONVERT(CHAR(8),(CONVERT(DATETIME,TimeStamp,113)),114), LogicName, PointValue FROM Trends order by LogicName"
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' I tried to remove one of the '0's but it still times out.
SQL = "SELECT top 100000 CONVERT(VARCHAR(10),TimeStamp,101) + ' ' + CONVERT(CHAR(8),(CONVERT(DATETIME,TimeStamp,113)),114), LogicName, PointValue FROM Trends order by LogicName"
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Interesting that this query runs fine. It takes a good 10 minutes to run
SQL = "SELECT top 100000 TimeStamp,LogicName, PointValue from Trends
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim objConnection,objRecordset,strSearchCriteria
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "Provider=sqloledb;Data Source=" & Datasource & ";Initial Catalog=" & DatabaseName & ";User Id=" & DBUser & ";Password=" & DBPassword
'MsgBox "Connected"
objRecordset.Open SQL, objConnection, adOpenStatic, adLockOptimistic
最佳答案
通过不要求 1000000 条记录解决了问题。相反,我更改了他的脚本以获取所需日期之间的所有记录。
关于sql - 查询超时过期80040E31,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44211263/