![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, I need to have a dts package that creates a text file dynamically to archive data from table.The file name needs to be in the format of currentdate_table.txt and only one file needs to be created per year.So if the DTS is on any day other than 1st jan then the data needs to be appended to the already existing file which was created the 1st day of that year.Is this doable and if so how? Your help would be really appreciated. |
#3
| |||
| |||
|
|
Hi, I need to have a dts package that creates a text file dynamically to archive data from table.The file name needs to be in the format of currentdate_table.txt and only one file needs to be created per year.So if the DTS is on any day other than 1st jan then the data needs to be appended to the already existing file which was created the 1st day of that year.Is this doable and if so how? Your help would be really appreciated. |
#4
| |||
| |||
|
|
One way to do this is to use an ActiveX script task at the beginning of your package to check the date. If the month and day are each equal to 1, you know you need to create a new file. Create the file using FSO and then set your text file connection to the new file name using the dynamic property task. ActiveX Script Task: Function Main() dim MMonth, DDay, YYear MMonth = DatePart("m", Date) DDay = DatePart("d", Date) YYear = DatePart("yyyy", Date) If MMonth = 1 and DDay = 1 then 'create a new file dim fso, ArchiveFile, FName set fso = CreateObject("Scripting.FileSystemObject") ' build filename based on current date FName = "D:\" + CStr(YYear) + Right("0" + CStr(MMonth), 2) + Right("0" + CStr(DDay), 2) + "_table.txt" DTSGlobalVariables("TextFileName") = FName ' the true argument causes an existing file to be overwritten set ArchiveFile = fso.CreateTextFile ( FName, true) ' write headings with pipe delimters; you might not need this for your specific package ArchiveFile.WriteLine ("Heading1|Heading2|Heading3") ArchiveFile.Close set fso = nothing set ArchiveFile = nothing End If Main = DTSTaskExecResult_Success End Function Dynamic Property task that sets the DATASOURCE property for the DESTINATION TEXT FILE connection to the global variable, TextFileName, which was set in the ActiveX script above. DB Source connection - data pump - Destination Text File: The data pump task will automatically append records to the file. Hope this helps. "Confused User" wrote: Hi, I need to have a dts package that creates a text file dynamically to archive data from table.The file name needs to be in the format of currentdate_table.txt and only one file needs to be created per year.So if the DTS is on any day other than 1st jan then the data needs to be appended to the already existing file which was created the 1st day of that year.Is this doable and if so how? Your help would be really appreciated. |
#5
| |||
| |||
|
|
Hi, I need to have a dts package that creates a text file dynamically to archive data from table.The file name needs to be in the format of currentdate_table.txt and only one file needs to be created per year.So if the DTS is on any day other than 1st jan then the data needs to be appended to the already existing file which was created the 1st day of that year.Is this doable and if so how? Your help would be really appreciated. |
![]() |
| Thread Tools | |
| Display Modes | |
| |