SSIS 2005 to export to Excel - refresh data every 4 hours

allenkent used Ask the Experts™
I have my SSIS package working and it runs ok the first time. What I cannot figure out is once the Excel spreadsheet is created the first time I cannot run the package again. I need a way to delete the whole file so it recreates with new data or delete all the data from the excel file and repopulate. I can seem to figure out this step.

My goal is basically have new data in Excel spreadsheet from my SQL database every 4 hours. I understand how to create my job on a schedule but the missing portion is deleting this excel file.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You can delete existing excel file using Execute SQL Task or File system Task

Add anyone of the task at first before spreadsheet creation task.

1. If you go with Execute SQL task  just write the below sql statement the in the task.
           xp_cmdshell 'del D:\abc.xlsx'

2. If File system taks. set the variable showing in image.



Perfect.  I used File system Task. I put step on the first line of my Control Flow and worked.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial