How to Export data to Excel in SQL Server using SQL Jobs
Asked Answered
I

2

6

I need to export the data from a particular table in my database to Excel files (.xls/.xlsx) that will be located into a shared folder into my network. Now the situation is like this -

  1. I need to use SQL SERVER Agent Jobs. 2.I need to generate a new excel file in every 2 minutes that will contain the refreshed data.

    I am using sql server 2008 that doesn't include BI development studio. I'm clueless how to solve this situation. First, I'm not sure how to export the data using jobs because every possible ways I tried had some issues with the OLEDB connection. The 'sp_makewebtask' is also not available in SQL 2008. And I'm also confused how to dynamically generate the names of the files.

    Any reference or solution will be helpful.

Impetus answered 27/9, 2013 at 9:20 Comment(0)
I
2

I found a better way out. I have created a SSIS(SQL Server Integration Services) package to automate the whole Export to Excel task. Then I deployed that package using SQL Server Agent Jobs. This is a more neat and clean solution as I found.

Impetus answered 13/3, 2014 at 11:54 Comment(2)
Could you share what you did in SSIS?Shipowner
This are the very basic, ready-made steps in SSIS. You just need to configure the steps as per your requirement. This link should help you - oakdome.com/programming/SSIS_DataTransform.php @ShipownerImpetus
H
5

Follow the steps given below :

1) Make a stored procedure that creates a temporary table and insert records to it.

2) Make a stored procedure that read records from that temporary table and writes to file. You can use this link : clickhere

3) Create an SQL-job that execute step 1 and step 2 sequentially.

Hyder answered 27/9, 2013 at 9:41 Comment(0)
I
2

I found a better way out. I have created a SSIS(SQL Server Integration Services) package to automate the whole Export to Excel task. Then I deployed that package using SQL Server Agent Jobs. This is a more neat and clean solution as I found.

Impetus answered 13/3, 2014 at 11:54 Comment(2)
Could you share what you did in SSIS?Shipowner
This are the very basic, ready-made steps in SSIS. You just need to configure the steps as per your requirement. This link should help you - oakdome.com/programming/SSIS_DataTransform.php @ShipownerImpetus

© 2022 - 2024 — McMap. All rights reserved.