dbTalk Databases Forums  

Problem to generate unique excel file by appending date using SSIS

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


Discuss Problem to generate unique excel file by appending date using SSIS in the microsoft.public.sqlserver.dts forum.



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

Default Problem to generate unique excel file by appending date using SSIS - 07-28-2009 , 02:24 AM






Am using SSIS to create an excel file. It works fine the first time but later
crashes as it ask to re creat the excel destination table. I found a solution
whch was to drop and create the table. Now my file contents are overwritten
BUT how to dynamically rename it with a proper timestamp

Reply With Quote
  #2  
Old   
Todd C
 
Posts: n/a

Default RE: Problem to generate unique excel file by appending date using SSIS - 07-29-2009 , 02:08 PM






Am I correct in saying that you want to create an Excel file with a new name,
and that new name should have a date/time stamp in the filename?

Working with Excel tables in SSIS is quite tricky. You can issue a command
"CREATE TABLE ..." which will create *both* a table and a new tab for the
table with the same name as the table. If you try to "DROP TABLE ..." then
only the info on the tab goes away, but the tab does not so any subsequent
"CREATE TABLE" statement will fail. (Thank you Microsoft for not thinking
this one through all the way.)

The standard suggestion out there is to create a template Excel file and
save it in a location where your package can get to. Then do a File System
task and copy/remane the file to where you want it. This circles us around to
your intial intent: get a Date/Time stamp in the file name:

Try incoprorating an Expression in either a FileName varialbe that is the
destination of the File System task, or an Expression that is used for the
Connection String of your Excel file. You will want to do something like this:
"FileName_" + (DT_STR, 50,1252)
(YEAR(System::ContainerStartTime)*10000+MONTH(Syst em::ContainerStartTime)*100+DAY(System::ContainerS tartTime)) + ".xls"

That will yield "FileName_20090727.xls"

HTH
Check back here if you need additional help.
=====
Todd C


"SSIS_Beginner" wrote:

Quote:
Am using SSIS to create an excel file. It works fine the first time but later
crashes as it ask to re creat the excel destination table. I found a solution
whch was to drop and create the table. Now my file contents are overwritten
BUT how to dynamically rename it with a proper timestamp

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.