简体   繁体   English

在MS Access 2007中的ODBC表上导入SQL查询

[英]Import sql query on ODBC table in MS Access 2007

Using MS Access 2007 I would like to retrieve only part of an ODBC table. 使用MS Access 2007,我只想检索ODBC表的一部分。 I can import the whole table in Access but I don't need all of it and it would be a waste of space and performance to store the whole table when I only need certain columns. 我可以在Access中导入整个表,但是我不需要全部,当我只需要某些列时,存储整个表会浪费空间和性能。

In Excel I wrote a SQL query that let me retrieve only the part I'm interested in. What I'd like to know is: is it possible to import only the result of a SQL query in Access or do I have to retrieve the whole table and then run the query on it? 在Excel中,我编写了一个SQL查询,仅让我检索自己感兴趣的部分。我想知道的是:是否可以仅在Access中导入SQL查询的结果,还是必须检索整个表然后在上面运行查询吗?

Is it possible using built-in Access module or should I turn to VBA? 是否可以使用内置的Access模块​​,还是应该转向VBA?

Edit: Basically I would like to run the ODBC data connection below (currently used in Excel) in Access. 编辑:基本上我想在Access中运行下面的ODBC数据连接(当前在Excel中使用)。

Connection string: 连接字符串:

DSN=BLA1;
UID=BLA2;
DBQ=BLA3;
PWD=BLA4;
DBA=W;
APA=T;
EXC=F;
FEN=T;
QTO=T;
FRC=10;
FDL=10;
LOB=T;
RST=T;
GDE=F;
FRL=F;
BAM=IfAllSuccessful;
MTS=F;
MDI=F;
CSR=F;
FWC=F;
PFC=10;
TLO=0;

Command string: 命令字符串:

SELECT *
FROM TEST TEST
WHERE (TEST.DATE_STAMP=?)

When I try to link the database I get the error The database engine can't find 'WTD.DATAPOINT_5/1000'. Make sure it is a valid parameter or alias name, that it doesn't include characters or punctuation, and that the name isn't too long. 当我尝试链接数据库时,出现错误The database engine can't find 'WTD.DATAPOINT_5/1000'. Make sure it is a valid parameter or alias name, that it doesn't include characters or punctuation, and that the name isn't too long. The database engine can't find 'WTD.DATAPOINT_5/1000'. Make sure it is a valid parameter or alias name, that it doesn't include characters or punctuation, and that the name isn't too long. but when I use the Excel database connection I get no error and everything is updated. 但是,当我使用Excel数据库连接时,没有任何错误,并且所有内容均已更新。

You don't need to import the whole table. 您不需要导入整个表。 You could link to the ODBC table and then run a make-table query against that linked table to copy in only the rows and columns that you need. 您可以链接到ODBC表,然后针对该链接表运行生成表查询,以仅复制所需的行和列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM