Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Exporting MS SQL results directly to Excel

Posted on 2011-03-15
5
Medium Priority
?
222 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 2000 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

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Question has a verified solution.

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

This article discusses how to implement server side field validation and display customized error messages to the client.
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
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.
Suggested Courses

927 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