473,529 Members | 2,521 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Export query result to csv file

xxoulmate
77 New Member
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 8603
Delerna
1,134 Recognized Expert Top Contributor
You could link an excel worksheet as a table and run an insert query into the linked worksheet.
Apr 23 '09 #2
xxoulmate
77 New Member
how about in sql query., is there a way to do it in pure sql statement
Apr 23 '09 #3
Delerna
1,134 Recognized Expert Top Contributor
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 Recognized Expert Top Contributor
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,561 Recognized Expert Moderator MVP
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
1920
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 people can right click and download. The downside of this, however, is that the file stays on the server and theoretically and anybody could find the...
11
4170
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 direct access to the db server. I'd like to give her the facility to export the information in her local Access application to the shared...
1
17923
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 '/tmp/result.txt' FROM table which generated an error message: Didn't expect "OUTFILE" after the SELECT column list.
3
36047
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 export it to an ascii file delimited. (Quote delimited with comma) - I tried to export to an ascii but I am getting: Too few parameters. It would be...
0
4185
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 applications! The function that does this work is: create_file_from_SQL_SEP(SQL, File_name, sep) As Integer Parameters: SQL: You can pass a SQL...
1
9757
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 having I'd be most appreciative. The database is already constructed, I'm just wanting to export the data to an excel file. In short, I'm hoping...
2
16423
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 still see all the arabic text OK with no problem, but if I open the CSV file in Microsoft EXCEL, all the arabic text are busted and no longer...
3
10934
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 the menu bar, choose "Text" as the save format, and then select "fixed width" as the export format, I end up with a fixed width text file with no...
0
1725
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 executing a rather complicated query( _sqlCommand) from a connection to an SQL Server(defined in _connection). Later I fill the table dataTable with the...
8
18741
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", "C:\qryFFRDeFile.txt", True Access asks for a specification name, now here lies the challenge, how do I create an export specification I have...
0
7344
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7505
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7670
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7255
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
4835
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3334
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1716
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
901
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.