![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I'm using DTS to export data to a csv file. This will be scheduled to create a new file every day. How do I name each file with today's date? eg: 01012002.csv, 02012003.csv etc? Thanks Leslie |
#3
| |||
| |||
|
|
Hi Leslie, You need to use activeX script task to to this. Regards. JFB Here is an example: Function Main() Dim oConn, sFilename ' Filename format - exyymmdd.log sFilename = "ex" & Right(Year(Now()), 2) If Month(Now()) < 10 Then sFilename = sFilename & "0" & _ Month(Now()) Else sFilename = sFilename & Month(Now()) If Day(Now()) < 10 Then sFilename = sFilename & _ "0" & Day(Now()) Else sFilename = sFilename & Day(Now()) sFilename = DTSGlobalVariables("LogFilePath").Value & _ sFilename & ".log" Set oConn = DTSGlobalVariables.Parent.Connections("Text File (Source)") oConn.DataSource = sFilename Set oConn = Nothing Main = DTSTaskExecResult_Success End Function les> wrote I'm using DTS to export data to a csv file. This will be scheduled to create a new file every day. How do I name each file with today's date? eg: 01012002.csv, 02012003.csv etc? Thanks Leslie |
#4
| |||
| |||
|
|
Thanks JFB. I've only got as far as a simple DTS package that connects to a database then copies some data to a csv file. I have tried adding an activex script task based on your example to run on completion of the text file(destination) connection, but I don't know how to configure it. Do I have to create DTSGlobalVariables? Is Logfilepath the path to my csv file? eg: C:\folder\myfile.csv What is: DTSGlobalVariables.Parent.Connections("Text File (Source)") Leslie |
#5
| |||
| |||
|
|
Thanks JFB. I've only got as far as a simple DTS package that connects to a database then copies some data to a csv file. I have tried adding an activex script task based on your example to run on completion of the text file(destination) connection, but I don't know how to configure it. Do I have to create DTSGlobalVariables? Is Logfilepath the path to my csv file? eg: C:\folder\myfile.csv What is: DTSGlobalVariables.Parent.Connections("Text File (Source)") Leslie On Fri, 1 Aug 2003 17:04:48 -0400, "JFB" <jfb2002 (AT) directvinternet (DOT) com wrote: Hi Leslie, You need to use activeX script task to to this. Regards. JFB Here is an example: Function Main() Dim oConn, sFilename ' Filename format - exyymmdd.log sFilename = "ex" & Right(Year(Now()), 2) If Month(Now()) < 10 Then sFilename = sFilename & "0" & _ Month(Now()) Else sFilename = sFilename & Month(Now()) If Day(Now()) < 10 Then sFilename = sFilename & _ "0" & Day(Now()) Else sFilename = sFilename & Day(Now()) sFilename = DTSGlobalVariables("LogFilePath").Value & _ sFilename & ".log" Set oConn = DTSGlobalVariables.Parent.Connections("Text File (Source)") oConn.DataSource = sFilename Set oConn = Nothing Main = DTSTaskExecResult_Success End Function les> wrote I'm using DTS to export data to a csv file. This will be scheduled to create a new file every day. How do I name each file with today's date? eg: 01012002.csv, 02012003.csv etc? Thanks Leslie |
#6
| |||
| |||
|
|
Hi Leslie, If you create a xls file in you DTS pkg you should have this: 1.Create table 2.Connection1 (odbc) 3.Connection 2 (excel file) Create a ActiveX script task ( 4. ActiveX script task) Now you should refer this line to you excel file name. DTSGlobalVariables.Parent.Connections("Connection 2") You dont need to create a Global Variable, this line only gets the connection name into you active x script variable oConn. I hope this is clear for you. JFB les> wrote Thanks JFB. I've only got as far as a simple DTS package that connects to a database then copies some data to a csv file. I have tried adding an activex script task based on your example to run on completion of the text file(destination) connection, but I don't know how to configure it. Do I have to create DTSGlobalVariables? Is Logfilepath the path to my csv file? eg: C:\folder\myfile.csv What is: DTSGlobalVariables.Parent.Connections("Text File (Source)") Leslie On Fri, 1 Aug 2003 17:04:48 -0400, "JFB" <jfb2002 (AT) directvinternet (DOT) com wrote: Hi Leslie, You need to use activeX script task to to this. Regards. JFB Here is an example: Function Main() Dim oConn, sFilename ' Filename format - exyymmdd.log sFilename = "ex" & Right(Year(Now()), 2) If Month(Now()) < 10 Then sFilename = sFilename & "0" & _ Month(Now()) Else sFilename = sFilename & Month(Now()) If Day(Now()) < 10 Then sFilename = sFilename & _ "0" & Day(Now()) Else sFilename = sFilename & Day(Now()) sFilename = DTSGlobalVariables("LogFilePath").Value & _ sFilename & ".log" Set oConn = DTSGlobalVariables.Parent.Connections("Text File (Source)") oConn.DataSource = sFilename Set oConn = Nothing Main = DTSTaskExecResult_Success End Function les> wrote I'm using DTS to export data to a csv file. This will be scheduled to create a new file every day. How do I name each file with today's date? eg: 01012002.csv, 02012003.csv etc? Thanks Leslie |
![]() |
| Thread Tools | |
| Display Modes | |
| |