Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 ForEach Loop is Not Trapping File Name

Author  Topic 

jbates99
Constraint Violating Yak Guru

396 Posts

Posted - 2013-02-06 : 23:59:15
Hi all,
This should be a very easy thing to do in SSIS 2008 but I'm having problems.

I just want to loop thru all .txt files in C:\Source and MOVE each file to C:\Archive folder.

I have a ForEach Loop and a File System Task. When I run it, it fails in the File System task with error "Could not find file 'C:\Source\'

Notice the filename is missing so I need help to populate the file name. Do I do this in the ForEach Loop's Collection or a variable?

Thanks, Jack

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-02-07 : 00:05:13
you need to add a variable and map it inside ForEachLoop to get value during each iteration.

You need to select an appropriate property in For Each Loop (filename only, filename with extension, fully qualified) to get value in required format

see these examples

http://visakhm.blogspot.in/2012/05/package-to-implement-daily-processing.html
http://visakhm.blogspot.in/2012/12/selective-file-archiving-using-ssis.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

jbates99
Constraint Violating Yak Guru

396 Posts

Posted - 2013-02-12 : 17:24:06
Thank you, visakh16. This worked
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-02-13 : 04:45:52
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -