适用于Jet 4.0的EXCEL中的SQL与Microsoft OLE DB提供程序的任何引用/手册? [英] Any references/manuals on SQL in EXCEL with Microsoft OLE DB Provider for Jet 4.0?

查看:107
本文介绍了适用于Jet 4.0的EXCEL中的SQL与Microsoft OLE DB提供程序的任何引用/手册?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



$ p

例如,如何使用Microsoft OLE DB Provider for Jet 4.0连接到 EXCEL 中的SQL语法参考/手册?我写了类型日期的常量吗?



什么关键字/函数/子句可用?

解决方案

当使用Excel作为Jet 4.0数据源时,我最了解的是:



如何使用ADO与Visual Basic或VBA中的Excel数据



特别重要的是当现有列的总体数据类型包含混合数据类型



关于Microsoft OLE DB Provider for Jet 4.0,最相关的文章是这样的:



ADO提供程序属性和设置:Microsoft Jet 4.0提供程序属性



那就是说,Excel特定的细节更好覆盖在前面的文章中。



使用Excel和SQL时应注意的一个重要问题:



BUG:当您使用打开的Excel工作表查询时,会发生内存泄漏ActiveX数据对象(ADO)


什么ke ywords / functions /子句是
可用?


关于使用Jet 4.0 SQL,这篇文章是我最好的曾经发现:



中级Microsoft Jet 4.0 SQL



理论上, SQL部分应该是相关的,但它是一个特别低品质和Jet 4.0特别受到较差的覆盖。



再次,不是一切都会直接工作在Excel中。例如,尽管您可以使用 CREATE TABLE SQL DDL来创建新的工作表和工作簿,但是您不能创建 NOT NULL 能力列,因为这不是物理上可能的。此外,Excel的数据类型更少的粒度,例如大多数数字类型映射到 DOUBLE FLOAT 。对于可以在SQL中使用的表达式,Jet 4.0表达式服务以某种方式使用VBA表达式服务,



广义而言,Jet可以使用任何VBA 5.0(不是最新版本,即VBA 6.0)函数,它不是一种引用值的方法,而返回仅返回单个值的简单内在数据类型(无数组,无对象等) )。我认为我说正确的是,微软从未明确地发布了Jet 4.0支持的VBA功能的确定列表。但是,我相信以下文章中的列表恰好与Jet 4.0中可用的VBA函数列表完全一致:



如何配置Jet 4.0以防止不安全的功能在Access 2003中运行



(该列表位于使用Jet 4.0 Service Pack 3及更高版本的沙箱模式操作子视图下。)



请注意,Jet 4.0中的某些功能的行为不同比VBA。离开我的头顶,我可以想到两个。可以在Jet 4.0(无证件,AFAIK)中的快捷方式:$ V $ code> $ TRUE c> FALSE 条件被评估,在Jet 4.0中,仅评估匹配条件。 CDEC()(转换为 DECIMAL )函数是在Jet 4.0中损坏


如何编写类型日期的常量?
我的意思是,在SQL中表达
2011.01.20(这个常量值)的方式,例如,我是否使用
'2011-01-20'或#2011-01- 20#,还是
别的东西?


我知道这是一个字面值。
$ b

这与VBA相同,即#m / d / yyyy#,所以今天的日期将是#1 /二千零十一分之二十零#。但是,我更喜欢使用 ISO 8601 日期格式和单引号(用于可移植性),并始终包含时间字段(因为Jet 4.0具有一个时间数据类型,为 DATETIME ),并且为确保区域设置得以兑现,请使用 CDATE() cast to DATETIME function eg今天的日期将是 CDATE('2011-01-20 00:00:00')






[原来认为OP意味着如何创建一个类型为 DATE 的列?]



可以使用 CREATE TABLE DDL eg

  CREATE TABLE [Excel 8.0; DATABASE = C:\MyNewWorkbook.xls] .MyTable 

my_date_col DATETIME
);

请注意,Jet 4.0将遵守数据类型 DATETIME ,在Excel中编辑工作簿时没有这样的约束:如果表 Range 被扩展,而非时间数据被添加,那么数据类型看到由Jet 4.0可能会改变。





is there any references/manuals on SQL syntax in EXCEL connected with Microsoft OLE DB Provider for Jet 4.0 ?

For example, how do I write constants of type date?

What keywords/functions/clauses are available?

解决方案

When using Excel as a Jet 4.0 data source, the best reference I know of is:

How To Use ADO with Excel Data from Visual Basic or VBA.

Of particular importance is how an existing column's overall data type is determined when it contains mixed data types.

As regards the Microsoft OLE DB Provider for Jet 4.0, the most relevant article is this:

ADO Provider Properties and Settings: Microsoft Jet 4.0 Provider Properties

That said, the Excel-specific detail is better covered in the earlier article.

One important gotcha you should be aware of when using Excel and SQL:

BUG: Memory leak occurs when you query an open Excel worksheet by using ActiveX Data Objects (ADO)

What keywords/functions/clauses are available?

As regards using Jet 4.0 SQL, this article is the best I've ever found:

Intermediate Microsoft Jet 4.0 SQL

In theory, the SQL section of the Access Help should be relevant but it is of a particularly low quality and Jet 4.0 specifically suffers poor coverage.

Again, not everything will work directly in Excel. For example, though you can use CREATE TABLE SQL DDL to create a new worksheet and workbook, you can't create a NOT NULLable column because this isn't physically possible. Also, Excel's data types as less granular e.g. most numeric types map to DOUBLE FLOAT.

As regards expressions that can be used in SQL, the Jet 4.0 expression service somehow uses the VBA expression services. Broadly speaking, Jet can use any VBA 5.0 (not the latest version, being VBA 6.0) function that is not a method that involes values, and returns returns a single value, of simple intrinsic data types only (no arrays, no objects, etc). I think I am correct in saying that Microsoft have never explicitly published a definitive list of the VBA functions that are supported by Jet 4.0. However, I believe a list in the following article happens to coincide perfectly with the list of VBA functions that useable in Jet 4.0:

How to configure Jet 4.0 to prevent unsafe functions from running in Access 2003

(The list is in a table under the subheading "Use Sandbox mode operations with Jet 4.0 Service Pack 3 and later".)

Note that some functions behave differently in Jet 4.0 than in VBA. Off the top of my head, I can think of two. IIF() can shortcut in Jet 4.0 (undocumented, AFAIK): in VBA, both TRUE and FALSE conditions are evaluated, in Jet 4.0 only the matched condition is evaluated. CDEC() (cast to DECIMAL) function is broken in Jet 4.0.

how do I write constants of type date? I mean, the way to express 2011.01.20 (this constant value) in SQL, for example, do I use '2011-01-20', or #2011-01-20#, or something else?

I know this as a 'literal value'.

This is the same as VBA i.e. #m/d/yyyy#, so today's date would be #1/20/2011#. However, I prefer to use ISO 8601 date format and single quotes (for portability) and always include the time field (because Jet 4.0 has but one temporal data type, being DATETIME) and, to ensure regional settings are honoured, use the CDATE() cast to DATETIME function e.g. today's date would be CDATE('2011-01-20 00:00:00').


[Originally thinking the OP meant, "How do I create a column of type DATE?"]

you can use CREATE TABLE DDL e.g.

CREATE TABLE [Excel 8.0;DATABASE=C:\MyNewWorkbook.xls].MyTable 
(
 my_date_col DATETIME
);

Note that while Jet 4.0 will honour the data type of DATETIME, there is no such constraint when the workbook is edited in Excel: if the table Range is extended and non-temporal data added then the data type 'seen' by Jet 4.0 could change as a result.


这篇关于适用于Jet 4.0的EXCEL中的SQL与Microsoft OLE DB提供程序的任何引用/手册?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆