Solved

Exporting MS SQL results directly to Excel

Posted on 2011-03-15
5
212 Views
Last Modified: 2012-05-11
Hello,  is there a way to automatically have the results from a MS SQL query get expoerted directly to Excel?

To take it one step further I have a number of scripts that users need to have run every morning or some even just every Monday and I would like to be able to set them up so they automatically fire off and save the results to an Excel spreadsheet in a specific directory with a file name.  Is this possible in SQL?

Thanks,
John
0
Comment
Question by:JohnJMA
  • 2
  • 2
5 Comments
 
LVL 15

Expert Comment

by:colly92002
ID: 35142984
You could use Reporting Service subscriptions:
http://msdn.microsoft.com/en-us/library/ms159762.aspx
0
 
LVL 21

Accepted Solution

by:
Jason Yousef, MS earned 500 total points
ID: 35156586
Yeah, SQL server can do ANYTHING!!
basically you'll just write your script using "openrowset" and run it using "SQLCMD" .

here's SQLCMD tutorial:
http://www.techrepublic.com/blog/datacenter/using-sqlcmd-to-execute-sql-scripts/422

and here's how to build your export to excel query/;
http://www.mssqltips.com/tip.asp?tip=1202

and

http://jasonhaley.com/blog/post/2004/03/06/OPENROWSET-T-SQL-function.aspx

Also can be done in joomle, using PHP; if that's what you're looking for too.
http://extensions.joomla.org/extensions/core-enhancements/data-reports/7413

Hope that helps
Jason
0
 
LVL 21

Expert Comment

by:Jason Yousef, MS
ID: 35285991
John,

Any Luck?
do you need more help?

Jason
0
 

Author Comment

by:JohnJMA
ID: 35290282
Hello Jason,
I have been working on it.  I don't have a solid solution for it ye.  Had something else that came up that has taken most of my time.  I am going to look at SQLCMD a little more.  I would just like a straight dump to Excel from a MS SQL stored procedure.

John
0
 

Author Closing Comment

by:JohnJMA
ID: 35793987
Thanks forthe help.  I like the build export to excel solution.  I don't want to use reporting services becasue we are using Crystal Server and I also want to have them  run a solution and go right to excel.  These are for mostly automated processes.

Thans.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

896 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

16 Experts available now in Live!

Get 1:1 Help Now