473,417 Members | 1,555 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,417 software developers and data experts.

Want to dump SQL query results to Excel

I know this is a question that comes up frequently, but I have yet to find anything that works. Here is my situation:

Facts:
I have written a moderately complex query which creates 28 columns of data
Each column has a name {header}
It works

Challenge:
Run the query in SQL Query Analyzer and, as a part of the query execution, dump the information to Excel in text format.

I can do this manually by copy and paste but I have to add the headings one by one so I can live without unraveling this one, however, that is certainly unsatisfactory.

Can anyone help me?

cbjones {learning slowly}
Frustrated Newbie
May 23 '10 #1
3 2584
ADezii
8,834 Expert 8TB
@cbjones
You can use the TransferSpreadsheet() Method. The following Code will Export (Argument 1) the qryEmployees Query (Argument 3) to an Excel SpreadSheet (Argument 2) as Test.xls in the C:\Stuff\ Folder (Argument 4). The first Row of the SpreadSheet will consist of the Column Names (Argument 5 - True);
Expand|Select|Wrap|Line Numbers
  1. DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qryEmployees", "C:\Stuff\Test.xls", True
May 23 '10 #2
Thank you! I negected to mention that I am using MS SQL 2000 Server...

Now I show my newbie side:
I know I have made an mistake of some kind. I get the following error:
Could not find stored procedure 'DoCmd.TransferSpreadsheet'.

Questions:
Where is this code placed in my query?
Do I need to create a "C:/Stuff" directory?
Do I need to set up an Excel file?

Thanks again!
Struggling
May 23 '10 #3
ADezii
8,834 Expert 8TB
@cbjones
Where is this code placed in my query?
No where, it's executed independently of your Query.
Do I need to create a "C:/Stuff" directory?
No, create any Absolute Path that you wish.
Do I need to set up an Excel file?
No.
May 23 '10 #4

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

Similar topics

1
by: Suffrinmick | last post by:
Hello Everyone I've built a database using Access 2000 which includes a query which is built using a form containing filters. No problem. When I export the results of the query to excel, (File >...
0
by: savas_karaduman | last post by:
I am trying to create graph report with using query results. Query result show me `total quantities` for some related `category name`. When i attempt to create a Chart Report with wizard by using...
5
by: Simon | last post by:
Dear reader, With the export command you can export a query to Excel. By activate this command a form pop's up with the following text:
3
by: austin1539 | last post by:
I am trying to run an Access query from Excel. The query, called "ProdActs1" works in Access and is run from using information from a table called "Queries". When a button is clicked in Excel, data...
3
jamjar
by: jamjar | last post by:
Trying to Export the results of a Query to Excel without having the user have to leave the Switchboard. Tried DoCmd.OpenQuery "myQuery" DoCmd.RunCommand acCmdExport DoCmd.Close...
2
by: Himmel | last post by:
Hello! The reference database I currently use runs queries that pull data from hundreds of tables in order to create user-friendly form view. The problem is that these queries can take upwards of...
1
by: CoolFactor | last post by:
MY CODE IS NEAR THE BOTTOM I want to export this Access query into Excel using a command button on an Access form in the following way I describe below. Below you will find the simple query I am...
1
by: davidson1 | last post by:
Hai friends, In our college we have oracle database , i need the old records for testing my project , and the old records are in dump file. Now i need to tranfer the data from oracle dump file...
2
by: Marisol2 | last post by:
I have some queries in Access 2003 db that I have setup to display as pivots. I can go into design pivot table view and click on and then click on Export to Office MicroSoft Excel. The problem is I...
3
by: JimCarlson | last post by:
I've created a macro in Access 2003 to output a query into Excel. I have scheduled a Windows XP task to run daily to run the macro. I want the current values in the query to overwrite the current...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...

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.