dbTalk Databases Forums  

Writing to a destination file.

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


Discuss Writing to a destination file. in the microsoft.public.sqlserver.dts forum.



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

Default Writing to a destination file. - 08-22-2003 , 10:49 AM






Hi,

I've got a connection object which executes a view to populate a csv
destination file. I have an activex script which is suppose to set the
filename and path of the csv file on completion of the workflow. The format
of the filename is ProcessLog_YYYYMMDD.csv.

The problem I'm seeing is that the csv file name isn't being changed every
time the package executes. So if the file gets created with the following
name ProcessLog_20030822.csv, then next time it runs it uses the same
filename rather than ProcessLog_20030823.csv.

Anyone got any ideas what is causing this problem??

Thanks in advance.

Glenn.



Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Writing to a destination file. - 08-22-2003 , 10:52 AM






Have you got the datapump to "Close Connection on completion" in the
workflow.

Do you "Know" that it is resetting the filename ?

--


Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org

Reply With Quote
  #3  
Old   
Glenn Haworth
 
Posts: n/a

Default Re: Writing to a destination file. - 08-26-2003 , 03:45 AM



I've set the "Close Connection on completion" and still get the same
problem.

I wouldn't say it's reseting the file name but rather than generating a file
with a new one, it keeps using the same file name.

So it would generate a file with the following name
"ProcessLog_20030826_09_30_00.csv", then it keeps using this one rather than
generating a new one which has a time 5 minutes older. I know it's using
the same file as the time in the modified column in explorer changes
correctly.

Here's a copy of the activex script i'm using: -

Function Main()

mydate = now()

sFilename = "c:\ProcessReports\ProcessLog_" & Right(Year(mydate), 4)

If Month(mydate) < 10 Then sFilename = sFilename & "0" & _
Month(mydate) Else
sFilename = sFilename & Month(mydate)

If Day(mydate) < 10 Then sFilename = sFilename & "0" & _
Day(Mydate) Else sFilename =
sFilename & Day(mydate)

sFilename = DTSGlobalVariables("LogFilePath").Value & sFilename & "_" &
Replace(Time(), ":", "_") & ".csv"

Set oConn = DTSGlobalVariables.Parent.Connections("Destination File")

oConn.DataSource = sFilename

Set oConn = Nothing

Main = DTSTaskExecResult_Success

End Function


"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote

Quote:
Have you got the datapump to "Close Connection on completion" in the
workflow.

Do you "Know" that it is resetting the filename ?

--


Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org



Reply With Quote
  #4  
Old   
Glenn Haworth
 
Posts: n/a

Default Re: Writing to a destination file. - 08-26-2003 , 09:09 AM



Sorted now. Had to move the scripts position in the workflow as it was
executing after the file had been created.

Thanks and some of the examples on SQLDTS were helpful as well.

Glenn.


"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote

Quote:
Also note that even if you do loop this script then if the execution is
too
fast then the filename will be the same so in my example even though I
looped 10 times I actually only got 2 files.


--

----------------------------
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org



"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote

Is your script executed each loop ?

If it isn't then you are setting the filename once and never again so it
will remain static.

I used this and put it in a loop

Set up Loop AX Script (Loops 10*)
Your settings script
Datapump
Loop returner

Function Main()

mydate = now()
dim oConn

sFilename = Right(Year(mydate), 4)

If Month(mydate) < 10 Then
sFilename = sFilename & "0" & Month(mydate)
Else
sFilename = sFilename & Month(mydate)
End if

If Day(mydate) < 10 Then
sFilename = sFilename & "0" & Day(Mydate)
Else
sFilename = sFilename & Day(mydate)
End if
sFilename = DTSGlobalVariables("LogFilePath").Value & sFilename &
"_"
&
Replace(Time(), ":", "_") & ".csv"

Set oConn =
DTSGlobalVariables.Parent.Connections("Destination File")

oConn.DataSource = sFilename

Set oConn = Nothing

Main = DTSTaskExecResult_Success

End Function

--

----------------------------
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org



"Glenn Haworth" <a@b.com> wrote in message
news:OwARr46aDHA.3768 (AT) tk2msftngp13 (DOT) phx.gbl...
I've set the "Close Connection on completion" and still get the same
problem.

I wouldn't say it's reseting the file name but rather than generating
a
file
with a new one, it keeps using the same file name.

So it would generate a file with the following name
"ProcessLog_20030826_09_30_00.csv", then it keeps using this one
rather
than
generating a new one which has a time 5 minutes older. I know it's
using
the same file as the time in the modified column in explorer changes
correctly.

Here's a copy of the activex script i'm using: -

Function Main()

mydate = now()

sFilename = "c:\ProcessReports\ProcessLog_" & Right(Year(mydate),
4)

If Month(mydate) < 10 Then sFilename = sFilename & "0" & _
Month(mydate) Else
sFilename = sFilename & Month(mydate)

If Day(mydate) < 10 Then sFilename = sFilename & "0" & _
Day(Mydate) Else
sFilename
=
sFilename & Day(mydate)

sFilename = DTSGlobalVariables("LogFilePath").Value & sFilename &
"_"
&
Replace(Time(), ":", "_") & ".csv"

Set oConn =
DTSGlobalVariables.Parent.Connections("Destination File")

oConn.DataSource = sFilename

Set oConn = Nothing

Main = DTSTaskExecResult_Success

End Function


"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:OwIqaVMaDHA.1748 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
Have you got the datapump to "Close Connection on completion" in the
workflow.

Do you "Know" that it is resetting the filename ?

--


Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support 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.