sql - 查询超时过期80040E31

标签 sql sql-server vbscript

这个 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/

相关文章:

mysql - sql server 从列不相等的两个表中选择

c# - 数据库错误 : There is no row at position 0

sql-server - 条件为 COALESCE 的 SQL JOIN 是重复行

sqlalchemy.orm.exc.StaleDataError : DELETE statement on table 'library_category_items' expected to delete 1 row(s); Only 2 were matched

SQL Server 差异 : Web Edition vs Express Edition With Advanced Series

c# - "Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to OFF"带复合键

css - FireFox 格式化 VBScript 链接的问题

vbscript - 从当前 URL 中删除默认文档

python - 查找并编辑文本文件

sql - 如何在 T-SQL 中拆分以逗号分隔的重复字符串