Solved

Export SQL Server Table to Excel File

Posted on 2010-09-20
12
721 Views
Last Modified: 2012-10-02
Hi: I need to export any SQL server Table or Query into a EXCEL file, Excel File will be created from scratch, basically I'm looking for a module I can attach to my ASP program.
Sql server Web version 2008
Excel File could be 2003 or 2007
No bulk mode may apply since I need to manipulate excel file after export.
I saw T-SQL, problem is excel file will need to contain file structure prior exporting process
Regards
0
Comment
Question by:rubensc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 6

Expert Comment

by:maxy88
ID: 33719485
In Excel, go to Data->Import External Data. You have a number of choices:

1) Select Data->Import External Data->Import Data. Click on New Source button and go from there using the wizard. You can use an ODBC connector at this step if that makes it easier for you.
2) Select Data->Import External Data->New Database query.
3) Select Data->Import External Data->New Web query if this applies to you.
0
 
LVL 28

Expert Comment

by:sammySeltzer
ID: 33719494
Hi,

If I understand correctly, you want your ASP app to have the ability to export table data to an Excel file?

In other words, you would like a like or an icon that says, "Export to Excel".

Is that what you are trying to do?
0
 

Author Comment

by:rubensc
ID: 33719507
Hi Maxy88, not usefull, export process needs to be programatically in asp environment, not manual
Regards
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:rubensc
ID: 33719559
ammySeltzer: I need to create the logic behind the icon, for SQL 2000 I developed a dll, it uses DTC pump, and it works ok, we are moving to a new server using SQL 2008 and library does not work.

The process to have a module/library/query that can extract data from SQL to EXCEL file
Regards
0
 
LVL 28

Expert Comment

by:sammySeltzer
ID: 33719863
So, are you looking to do this using ASP?
0
 

Author Comment

by:rubensc
ID: 33720189
I can go two ways
1) A query  Transact SQL
2) A dll to invoke using server.createobject
regards
0
 
LVL 33

Expert Comment

by:Norie
ID: 33730411
If you already have something that does this and you know the logic behind that why not just apply that to the new situation.


Or is it actually the details of how to actually do the export?

You say the library you developed earlier won't work? How?

Could you not at least take any parts of it that do work as a basis?

Also how do you intend manipulating the newly created Excel file?

PS I assume it will be created because you seem to be saying that's what you need/want to do.
0
 

Author Comment

by:rubensc
ID: 33740262
imnorie: Imagine I don't have anything at all, I will need a new solution from scratch
Regards
0
 
LVL 33

Expert Comment

by:Norie
ID: 33740375
Well if I fully understood what you actually want to do I might make some suggestions but it's not clear, to me anyway.

In your first post you talked about wanting someting to  'attach to my ASP program', what do you mean by that.

You also seem to be ruling out certain methods eg 'no bulk method may apply'.

Then there's Excel, why does it need to contain a 'file structure' before export/import? What do you mean by 'file structure'?

One other thing you mention is that you want to manipulate what's been exported.

Do you simply mean you want Excel, with the exported data, to stay open after the export?
0
 

Accepted Solution

by:
rubensc earned 0 total points
ID: 33780429
HI: I resolve it using openrowset and creating the excel file before exporting data, now it works fine.
Thanks any way
0
 

Author Comment

by:rubensc
ID: 33780515
To export data use openrowset function, sql allows you to do that, review the following link

http://www.mssqltips.com/tip.asp?tip=1202

In other to export data the following conditions must meet
a) Excel file needs to be ready before exporting
b) Column Names need to match in query, not recomend to use select *, instead use select field1,field2,field3,... fieldn.
c) SQL property for this kind of query needs to be enable, as soon as you try the first query, SQL will tell whats wrong and the proper adjustment.

0
 
LVL 33

Expert Comment

by:Norie
ID: 33783051
I'm pretty sure you could have got that answer/suugestion a bit earlier if you had been a bit clearer in your question.
Anyway, you found a solution and that's the important thing.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question