Scenario:
There are different types of files we have in our Source folder. We want to archive them to Archive folder. While archiving them we want to add time-stamp with each file name.
Solution :
We will be using For-each loop and File System task to perform this task. Let's start with our step by step approach
Step 1:
Create two variable VarSourceFolder and VarArchiveFolder and provide the values
Step 2:
Bring For-each Loop container to Control Flow Pane and configure as shown below. I used the VarSourceFolder variable as Directory. If we need to change Source Folder Path,We do not have to open the package , Instead we can just change the value for this variable by using SSIS Configuration.
The Information we want to extract is File Name and extension , Choose that.
Create variable VarFileName to hold the FileName and extension
The For-each loop is loop through the folder files one by one and on each iteration file name and extension will be saved in VarFileName variable.
Step 3:
Create a new variable VarArchiveFullPath, Click on that and press F4, that will take you to properties. Go to expressions and paste below expression
@[User::VarArchiveFolder]+"\\"+ Replace(Replace(Replace(Replace( @[User::VarFileName],".","_"+Substring((DT_WSTR,50) GETDATE(),1,19)+"."),"-",""),":","")," ","_")
Set EvaluteAsExpression=True
Step 4:
Create a variable VarSourceFullPath, this will have Source Folder path and file name together. Write expressions on it as shown below
Step 5:
Bring File System task to Control Flow Pane and configure as shown below
Final Output:
Let's run our SSIS Package and see if files are moved and renamed.
As we can see that all the files are moved from Source Folder to Archive Folder successfully and Time-Stamp is also added.
Step 2:
Bring For-each Loop container to Control Flow Pane and configure as shown below. I used the VarSourceFolder variable as Directory. If we need to change Source Folder Path,We do not have to open the package , Instead we can just change the value for this variable by using SSIS Configuration.
The Information we want to extract is File Name and extension , Choose that.
Create variable VarFileName to hold the FileName and extension
The For-each loop is loop through the folder files one by one and on each iteration file name and extension will be saved in VarFileName variable.
Step 3:
Create a new variable VarArchiveFullPath, Click on that and press F4, that will take you to properties. Go to expressions and paste below expression
@[User::VarArchiveFolder]+"\\"+ Replace(Replace(Replace(Replace( @[User::VarFileName],".","_"+Substring((DT_WSTR,50) GETDATE(),1,19)+"."),"-",""),":","")," ","_")
Set EvaluteAsExpression=True
Step 4:
Create a variable VarSourceFullPath, this will have Source Folder path and file name together. Write expressions on it as shown below
Step 5:
Bring File System task to Control Flow Pane and configure as shown below
Final Output:
Let's run our SSIS Package and see if files are moved and renamed.
As we can see that all the files are moved from Source Folder to Archive Folder successfully and Time-Stamp is also added.
very useful information for us.
ReplyDeletebest cafe in chennai
Good information
ReplyDeletesecurity agency in chennai
best security service in chennai
National flags come in excess of twelve unique proportions, from the splendidly square Switzerland to the extended Qatar, the main Flags whose width is more than twice its tallness. Be that as it may, at the Olympics, for reasonableness, they are no different.
ReplyDeleteVisit: Flags Of The World
Extremely valuable and relevant information, much appreciated
ReplyDeletedata backup solutions for small business
Considerable article, I found this resource utmost beneficial for everyone,thank you for sharing the thoughts,We at Property Hunters shifted this service to a level much higher than the broker concept. If you willing to purchase property in Qatar please visit us,you can see more details like this article Properties For Sale in Qatar
ReplyDeleteI think this is a very useful way and tool in which one looks for solving more of complex IT problems and ways.One needs to emphasise more on this as well.
ReplyDeleteSSIS Postgresql Write
Mua vé máy bay tại Aivivu, tham khảo
ReplyDeletevé máy bay đi Mỹ bao nhiêu
vé bay từ mỹ về việt nam
mua vé máy bay từ đức về việt nam
vé máy bay nhật việt
khi nào mở lại đường bay hàn quốc
vé máy bay từ canada về việt nam bao nhiêu tiền
khách sạn cách ly ở việt nam