QODBC SQL问题

时间:2014-08-28 14:41:38

标签: odbc quickbooks

确定。在过去的几天里,我一直在努力做一些世界上最简单的报告......

因此,在确定了表关联并提取样本数据之后,我注意到我需要改变我如何提取数据。 部分原因是从发票表中提取年初至今。 然而,qodbc是愚蠢的(可能是我,但它让我觉得更好地责怪司机)

SELECT * FROM Invoice WHERE TimeCreated > '2014-01-01 00:00:00.000'一直给我Invalid operand for operator: >

的错误

搜索Google对我没有任何帮助 Soooo ...我需要帮助搜索日期字段。任何人都有任何想法或建议吗?

此外,奖励积分但相关......其他人对qodbc驱动程序的速度有问题吗?有些表可以像mysql一样快速搜索,但是有些表...神圣的废话。 10分钟的简单查询。提高那些速度的想法?

2 个答案:

答案 0 :(得分:3)

日期格式

SELECT *
from InvoiceLine
WHERE Txndate >= {d '2005-09-23'}

时间戳格式

SELECT *
FROM Customer
WHERE TimeCreated = {ts '1999-07-29 14:24:18.000'}

SELECT *
from InvoiceLine
WHERE TimeModified >= {ts '2005-09-23 00:00:00.000'}

参考:http://support.flexquarters.com/esupport/index.php?/Default/Knowledgebase/Article/View/2203/50/how-are-dates-formatted-in-sql-queries-when-using-the-quickbooks-generated-time-stamps

如何让QODBC更快地运行

  Keep in mind that QODBC is not a database tool, but rather a translation tool. QuickBooks is a non-normalized flat file system which has no indexes available and will not perform like SQL Server or dBase files. Every transaction you request must be translated and communicated to QuickBooks via large complicated XML transactions.

  Try and keep your result set as small as possible to get a feel for the system, carefully design and test any multi-file joins, and keep the number of returned fields to a minimum for maximum performance.

  Our main goal is to make it easier to access QuickBooks data in a standardised database-like fashion, but queries must be optimized to perform as fast as possible.

  Also, try and use ranges of dates on TxnDate, TxnDateMacro and TimeModified as much as possible to narrow down the data to the smallest possible segment. For example, make something similar to this in the first part of your WHERE clause:

  Invoice.TimeModified >= {ts'2003-09-01 17:01:09'} AND
  Invoice.TimeModified <= {ts'2003-09-02 17:01:09'}

我建议使用Optimizer. sp_optimizefullsync All

请参阅:如何设置QODBC Optimizer以及Optimizer选项在哪里可以获得有关优化程序的所有详细信息。 (http://support.flexquarters.com/esupport/index.php?/Default/Knowledgebase/Article/View/2358/48/how-to-setup-qodbc-optimizer-and-where-are-the-optimizer-options

  By default the optimizer will update new and changed entries in a table from QuickBooks first and then execute the query against the local optimized table. This is faster than reading everything out of QuickBooks every time, especially the more data you have. 

答案 1 :(得分:0)

从未使用此驱动程序,但请尝试此操作:

SELECT * FROM Invoice WHERE TimeCreated&gt; {d'2014-01-01 00:00:00.000'}

可能需要稍微调整一下日期字符串的格式,只是一个猜测。

就您选择的速度而言,如果查询具有WHERE子句,则可能会因为没有表上的索引而受到影响。带索引的表将比没有索引的表更快地返回结果。