Solved

Can I export SQL table output to excel?

Posted on 2011-03-18
5
593 Views
Last Modified: 2012-05-11
I have some SQL query's that output the data in table format when executed.  I am just wondering if there is a way to automatically pull the data from the table to an excel file.  Or more specifically, pull parts of the data to specific parts of an excel file.  Like say pull the data from the second column of the query ouput and place it in excel Column C (below current data if possible).  Or even match up dates (which are part of the SQL output) to the dates in column A of the excel file.

I have a feeling this isn't possible or is way more work then its worth, but I wanted to check and see.  I know I can highlight and copy data over, but I'm hoping for more automation.  Thanks for the help.
0
Comment
Question by:mjburgard
[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
5 Comments
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 250 total points
ID: 35169328

I doubt you could save it to excel in any simplistic manner, you would have to use the export data function.

Saving to a text file on the other hand is very simple, you could even save to a .csv file which you can open using excel.

Just go to the menu
Query->Results To

You have to options
1. Results To Text
2. Results To File
0
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 35169425
Can can always initiate the data connection from inside of excel, but it would take some fairly crafty VBA coding to do what you want to do.
0
 
LVL 3

Assisted Solution

by:a_hassaan
a_hassaan earned 250 total points
ID: 35169461
use "ETL" of microsoft Integration Services Project
it's very very easy... a flow chart drag and drop builder.
I can help you with that if you want.
and then you can export to excel, schedule your task, read from excel, or even send results by mail.

it's ETL = "Export Tranform & Load"
0
 
LVL 8

Expert Comment

by:Som Tripathi
ID: 35171725
You can directly Export table to Excel using T-SQL.

Please find the same script at -
http://mssqlserver.1talk.net/t53-export-sql-server-table-to-excel#60
0
 
LVL 1

Author Closing Comment

by:mjburgard
ID: 35193928
So its seeming like that I was correct in saying there is no easy way to do this.  Thanks for the other ideas, I'll look into them.
0

Featured Post

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
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 will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
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…

737 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