dbTalk Databases Forums  

Overwriting existing .csv and .xls files

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Overwriting existing .csv and .xls files in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Denise Watson
 
Posts: n/a

Default Overwriting existing .csv and .xls files - 09-18-2003 , 04:57 PM






I have 2 different DTS packages that create files weekly.
The one that creates the .csv file overwrites itself each
week with the updated information. The one that creates
the .xls file won't overwrite it. I tried deleting the
file each time, but if the file isn't there the DTS
package errors out. It seems the only way it will put in
fresh data is if the excel file already exists and is
empty.

Any ideas?

Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: Overwriting existing .csv and .xls files - 09-18-2003 , 05:21 PM






In article <057001c37e2f$ec0c5620$a401280a (AT) phx (DOT) gbl>, Denise Watson
<dwatson (AT) ksfcu (DOT) org> writes
Quote:
I have 2 different DTS packages that create files weekly.
The one that creates the .csv file overwrites itself each
week with the updated information. The one that creates
the .xls file won't overwrite it. I tried deleting the
file each time, but if the file isn't there the DTS
package errors out. It seems the only way it will put in
fresh data is if the excel file already exists and is
empty.

Any ideas?
You can check if the file exists before deleting it to prevent the
package failure.

If using ActiveX Script -

Working with files and the FileSystemObject
(http://www.sqldts.com/default.aspx?292)

If using DOS then you can use "if exists" but you will probably have to
wrap this in a batch file.

When working with Excel files (not CSV though) I have found it easiest
to create a template file which is basically a blank file with
formatting that I want and copy that to the destination file location
immediately prior to export. With CSV you can just delete any existing
files and re-create it from DTS.

--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.