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

Can I export SQL table output to excel?

Posted on 2011-03-18
5
591 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
5 Comments
 
LVL 32

Accepted Solution

by:
ewangoya 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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