Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Empty Excel Sheet from DTS

Status
Not open for further replies.

rwttm001

IS-IT--Management
Nov 20, 2002
26
GB
Hi

My package runs fine, exporting 4 SQL views and 1 Access 97 query into 5 tabs in a destination Excel file. However when I run at again the new data is simply appended onto the end of the existing data.

I need to make it so that every time the package runs the Excel sheet only has the contents of the data at that particular time, any help greatly appreciated.

TIA
 
You should think about using CSV rather than XLS. If you really need to use XLS one way to approach is Create a template of the file and keep in a backup folder.
First step of your DTS should be delete the current file and copy the empty template.
Try the below script.
GO
exec master.dbo.xp_cmdshell 'DEL C:\EXCEL\*.XLS'
GO
exec master.dbo.xp_cmdshell 'copy C:\EXCEL\BAK\TEMPLATE.XLS C:\EXCEL\BAK\'
go


Dr. Sql
goEdeveloper@yahoo.com
Good Luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top