自动转换访问数据库 [英] automatically convert access db

查看:58
本文介绍了自动转换访问数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个访问数据库,并进行了查询.我需要对其进行自动化,以便该查询每天晚上都可以运行并导出到以制表符分隔的csv文件.无法从访问权限中将查询导出到csv文件.我的问题是,是否有任何工具可以选择某些表,或对mdb文件执行sql查询,然后导出到csv文件?

I have an access database, with a query made. I need to automate it so that each night this query can run and export to a tab delimited csv file. It is not possible to export a query to a csv file from within access. My question is, are there any tools that can select certain tables, or perform an sql query on an mdb file, and export to a csv file?

推荐答案

实际上,您可以在Access中将查询导出到csv文件.

Actually, you can export a query to a csv file from within Access.

您可以使用TransferText方法对宏进行此操作.

You can do this with a Macro using the TransferText method.

宏:

   Name = ExportQuery
   Action = TransferText
   Transfer Type = Export Delimited
   Table Name = [name of your Access query]
   File Name = [path of output file]
   Has Field Names = [Yes or No, as desired]

您可以从命令行执行该宏,如下所示:

You can execute the macro from the command line like this:

"[your MS Office path]\msaccess.exe" [your databse].mdb /excl /X ExportQuery /runtime

由于您无法在宏中使用TransferText,请尝试以下操作:

Since you're having trouble with TransferText in a macro try this:

1)创建一个名为"ExportQuery"的模块.在此模块中,创建一个名为"ExportQuery"的函数:

1) Create a Module named "ExportQuery". In this module, create a function called "ExportQuery":

Function ExportQuery()
    DoCmd.TransferText acExportDelim, , "[your query]", "[output file].csv"
End Function

2)创建一个名为RunExportQuery的宏:

2) Create a Macro named RunExportQuery:

Action = RunCode
Function Name = ExportQuery ()

这篇关于自动转换访问数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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