Solved

Exporting MS SQL results directly to Excel

Posted on 2011-03-15
5
216 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

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

Suggested Solutions

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

821 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