Click here to Skip to main content
15,891,926 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Guys,

I have a requirement where I need to prepare a report everyday. I need to query the database(SQL Server 2008) to pull out the data and export data to an excel and send the same to the client.
I want to automate it i.e., the data should be exported to excel automatically and the file should be placed in a specific location.
Please help how to implement this functionality. I am using SQL server 2008.

TIA.
Posted
Comments
[no name] 21-May-14 11:55am    
So create a scheduled task.
Naveen K M 21-May-14 12:20pm    
Before scheduling the task we should write console applicaion right? I am asking how to do that
Maciej Los 21-May-14 14:48pm    
No, you don't. I haven't see question about console application. You should be more specific and provide more details about your issue.
[no name] 21-May-14 15:01pm    
How to do what exactly? Create a console app? Start Visual Studio, click File->New project and select console application, then start coding. Be specific about where you are stuck. We are not going to design your entire application for you.
Maciej Los 21-May-14 14:46pm    
What have you done? Where are you stuck?

1 solution

You have two big choices:

1. To create the target Excel workbook every time.
2. To update the data in the existing Excel workbook.

Look this article if you want to create the workbook:
http://www.excel-sql-server.com/sql-server-export-to-excel.htm[^]

The second way is based on using a script that does the following:

1. Opens the workbook.
2. Updates connected tables.
3. Closes the workbook.

This is a good solution as you can customize workbooks for your customers.
You may find ready scripts for this task.

You also have the third way.

You may add your customers to your database and give them permissions to execute several stored procedures to get the data.

As a result, your customers can update the data when they want.
You do not send any file on daily basis.

In addition, you may use the free SaveToDB Express add-in to use Excel as a feature-rich reporting tool.
http://www.savetodb.com/help4/savetodb-getting-started.htm[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900