Solved

Export SQL Server Table to Excel File

Posted on 2010-09-20
12
713 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
  • 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
 

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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Sql query 34 22
When to use an Aggregate Function. 18 38
Excel Difference between 2013 and 2016 2 16
SQL Query 3 0
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now