SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


how to copy for a file in sub directories basing on the file name in ssis


how to copy for a file in sub directories basing on the file name in ssis

Author
Message
SQL_Buddy99
SQL_Buddy99
SSC Veteran
SSC Veteran (258 reputation)SSC Veteran (258 reputation)SSC Veteran (258 reputation)SSC Veteran (258 reputation)SSC Veteran (258 reputation)SSC Veteran (258 reputation)SSC Veteran (258 reputation)SSC Veteran (258 reputation)

Group: General Forum Members
Points: 258 Visits: 398
How to copy a particular file from sub folders basing on the file name. I have multiple sub folders and the file which i am looking for may present in the sub folder level or it may be present in another sub folders under the present sub folder. can any of you guys help me in this
MReedSQLBi
MReedSQLBi
Grasshopper
Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)

Group: General Forum Members
Points: 11 Visits: 48
My suggestion...
Drag a ForEach Loop container onto the Workflow tab
Drag a FileSystem task into the ForEach Loop container

Configure the ForEach Loop container as follows:
On the General tab...
- Name the task appropriately
On the Collection tab...
- Specify the Enumerator type...in your case "For Each File"
- Specify the (Parent) Folder path
- Provide the file name and extension attributes ( *.txt, myfile*.txt, etc)
- Specify how you want the file name returned. If you want to keep it simple then return the fully qualified file name which includes the file system path
- Specify if you want to search all subfolders
On the Variable Mapping tab..
- Click in the Variable box and select New Variable. Name it FQFileName.
- Set the data type to String
Exit Edit on the ForEach Loop Container

Configure the FileSystem task:
On the General tab...
- Set the Destination connection as needed...in your case it should be a folder...existing or create
- Specify whether to Overwrite or not
- Set the operation to Copy File
- Set the Is Source Path Variable to True
- Set the Source Variable to User::FQFileName from the dropdown list

When you execute the package it will find all files that match the source name pattern you provided in the folder structure you specified and copy them into the destination folder you specified.

HTH
MReed
Pragmatic Works
SQL_Buddy99
SQL_Buddy99
SSC Veteran
SSC Veteran (258 reputation)SSC Veteran (258 reputation)SSC Veteran (258 reputation)SSC Veteran (258 reputation)SSC Veteran (258 reputation)SSC Veteran (258 reputation)SSC Veteran (258 reputation)SSC Veteran (258 reputation)

Group: General Forum Members
Points: 258 Visits: 398
Thanks a lot for your help. Struggled for a day with this. But looks very simple and clear.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum







































































































































































SQLServerCentral


Search