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
Solved

Export SQL Server Table to Excel File

Posted on 2010-09-20
12
720 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

809 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