?
Solved

Export SQL Server Table to Excel File

Posted on 2010-09-20
12
Medium Priority
?
732 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 29

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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 

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 29

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 34

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 34

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 34

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

800 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