473,394 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Export query result to csv file

xxoulmate
i wanted to export the query result into csv file
is there any way to do it.,


e.g. select field1,field2 from table into csvfile
Apr 23 '09 #1
5 8592
Delerna
1,134 Expert 1GB
You could link an excel worksheet as a table and run an insert query into the linked worksheet.
Apr 23 '09 #2
how about in sql query., is there a way to do it in pure sql statement
Apr 23 '09 #3
Delerna
1,134 Expert 1GB
Not that I am aware of.
You coud do it with a combination of VBA, (DAO or ADO) and VBA file handling functionality.

Open a text file object
Open A recordset object from your query
loop through each record
add each fields content separated with commas to the file
close the recordset object
close the file object



You could also do a similar thing with vbscript and the File system object.
Again using ADO to query the DB
The advantage there would be you could schedule the script to run automatically.
If that was important.
Apr 23 '09 #4
Delerna
1,134 Expert 1GB
well, time to take foot out of mouth :)

1) Create your csv file
2) Add 1 row of comma separated data.
3) Link the csv file as a table. (there must be at least 1 row of data or it wont link)
4) Create your query and make it an append query (into the linked csv)
5) Run the query
6) Close Database
7) Open csv file and VOILA
Apr 23 '09 #5
NeoPa
32,556 Expert Mod 16PB
An alternative would be to create a simple SELECT QueryDef, and Export (File / Export...) this into your new CSV file.
Apr 23 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: bigoxygen | last post by:
Hi. I would like to offer the users of my web application the ability to export data in the csv format. What I have come up with currently is writing the stream of data into a csv file which...
11
by: Mike MacSween | last post by:
My client has an MS Access database application on her local machine. I have full access to that in terms of changing the design. I've got a simple PHP/MySql application on shared hosting, so no...
1
by: Akosko | last post by:
Hi there, I need to dump some data from a db by using MS Query. I noticed couple of issues during my attempts to do so. However I tried to run a query like: SELECT table.column INTO OUTFILE...
3
by: azzi2000 | last post by:
This should be rather simple. I have a query using different link tables and 2 parameters. The query works perfect. However I need to export or save the result in an Access table in order to...
0
MMcCarthy
by: MMcCarthy | last post by:
This is a module that exports information from a Query or a Table to comma separated values in a text format, or using other symbol! It is very helpful for sharing information between the...
1
by: smaczylo | last post by:
Hello, I've recently been asked to work with Microsoft Access, and while I feel quite comfortable with Excel, I'm at a complete loss with databases. If someone could help me with this issue I'm...
2
by: farukcse | last post by:
Dear Sir, I have a PHP script that export CSV with arabic text, for example I download the CSV on the website then save to desktop of my computer and Open it on NOTEPAD... that works fine I could...
3
by: Wayne | last post by:
I'm trying to automate the export of a query to a text file using code. If I export the query manually I get the exact result that I want i.e. If I select the query then choose File/Export from...
0
by: chago | last post by:
Hi all, I am trying to adapt a program, by transforming the output part of it, so it can export to ODBC(SAS), as previously it exported to plain text. Thus I create an SqlDataAdapter "da" by...
8
by: iheartvba | last post by:
Hi I am using Access 2007 and am trying to export a query to a fixed length text file. I tried using the following code to export the text file: DoCmd.TransferText acExportFixed, , "qryFFRDeFile",...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.