March 21, 2012 at 9:08 pm
Hi ,
I am recieving flat files from FTP site whose file names are different but receiving from same location everyday. usi
I would like to Rename *.csv files to Daily_files.csv in SSIS 2008.
weekly files:
1st day : Daily_files_03/01/2012.csv
2nd day : Daily_files_03/02/2012.csv
3rd day : Daily_files_03/05/2012.csv
and so on....
I tried file system task with rename option but it is not working.
Please give me suggestions without using file system task and Execute Process Task.
thanks,
J
March 22, 2012 at 12:08 am
1. Create code like below in Script Task: v_FileName is your source file.[C:\<Your File Name>.csv]
Dim vFileName, vDate, vFilePath As String
vFileName = CStr(Dts.Variables("v_FileName").Value)
vDate = Now.Date.ToString("MM/dd/yyyy")
vDate = Replace(vDate, "/", "")
vFileName = Replace(vFileName, ".csv", "")
vFilePath = vFileName & "_" & vDate & ".csv"
Dts.Variables("v_TextFileName").Value = vFilePath
Dts.TaskResult = Dts.Results.Success
2. Using File System Task rename yoru file.
Source is your variable: v_FileName
Destination is your destination variable. v_DestinationFileName
Create variables like below:
v_FileName as string [C:\<Your File Name>.csv]
v_DestinationFileName as string [C:\<Your File Name>.csv]
March 22, 2012 at 1:11 am
jasminipatel51181 (3/21/2012)
I tried file system task with rename option but it is not working.
Can you be a bit more specific? Are there errors or do you not get the desired results?
Or do you go to the garage with your broken car and you say to the mechanic: "Car is broke. Plz fix."?
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
March 22, 2012 at 8:24 am
Thanks for the reply.
my File name is not fixed it varies every day.
Thanks,
J
March 22, 2012 at 8:36 am
jasminipatel51181 (3/22/2012)
Thanks for the reply.my File name is not fixed it varies every day.
Thanks,
J
Well that clears things up.
Personally, I'd keep the file name as-is and instead use a FOREACH loop to pick it up, passing the file name to a flat file datasource configured to pick up the file (via use of an expression).
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply