简体   繁体   中英

How to Export data to Excel in SQL Server using SQL Jobs

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM