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 2005 Forums
 SSIS and Import/Export (2005)
 SSIS - FTP Task

Author  Topic 

ykram511
Starting Member

4 Posts

Posted - 2008-05-09 : 02:25:48
Sorry guys, I'm really new to this. Can somebody tell me the easiest way to use the FTP task with a dynamic local path. I just want the FTP task to send whatever file is in the directory I specify.

I'm creating a package that extracts data from a table to a pipe-delimited file. I then use an external process (since using Expressions for it was a nightmare) to rename the file so that it'll reflect the previous month (e.g. April2008_report.txt). Then, I have to FTP that file. That's where my problem is. It seems I need to specify the exact filename on the local path of the FTP task, and since the filename will change each month... well, you see my problem.

Is there a way to tell the FTP task to just send *.txt, or something to that effect?

Thanks in advance for you help!

Thanks,

Mark

rgombina
Constraint Violating Yak Guru

319 Posts

Posted - 2008-05-09 : 07:11:35
User Foreach File System container to loop through files in the folder. Once file is located or present then save it to a variable so that you can pass the value to the FTP Task (this is inside the loop container). In the Foreach loop container you can specify all, specific files or mixed and matched.
Go to Top of Page

ykram511
Starting Member

4 Posts

Posted - 2008-05-10 : 21:27:24
Hi,

It works great! Cool!

One question though...

I was exploring the FTP Task properties and noticed the IsLocalPathVariable property. Is there a way I can set this to True and then use the same variable set dynamically by my destinationflatfile connection object, whose default value is, say, "c:\report\", with the filename set dynamically using expressions? What I mean to say is, a solution without using a foreach loop container. Although the foreach loop works fine, I was just wondering, since I will always have just one file on that folder, if I can forego the use of the foreach loop, since the localpath property of the ftp task can obviously be set to a variable.

I actually tried something like this, but got the following error, on which I'm pretty much stumped:

Error: Failed to lock variable "c:\report\April2008_report.txt" for read access with error 0xC0010001 "The variable cannot be found. This occurs when an attempt is made to retrieve a variable from the Variables collection on a container during execution of the package, and the variable is not there. The variable name may have changed or the variable is not being created."

I did check my variable again and everything seems fine: scope, value, name.

Any ideas what I'm doing wrong?
Go to Top of Page

rgombina
Constraint Violating Yak Guru

319 Posts

Posted - 2008-05-12 : 08:06:03
Wait, the name of the variable is the file location? It seems like that's what the error is complaining. If you always have the same filename you can just create another variable and set value to local path. I'm just trying to understand what you're trying to do and perhaps there's a simplier approach.

Looking ahead question - if you're not going to use Foreach Loop, how will your package know which next month's filename to use since it looks like monthly naming convention? Just curious.
Go to Top of Page

wappalysta
Starting Member

1 Post

Posted - 2011-07-26 : 13:04:02
quote:
Originally posted by rgombina

User Foreach File System container to loop through files in the folder. Once file is located or present then save it to a variable so that you can pass the value to the FTP Task (this is inside the loop container). In the Foreach loop container you can specify all, specific files or mixed and matched.




Not finding how to save the filename to a variable and then pick it up in a File Task in the loop container. Any assistance would be appreciated.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-07-26 : 13:24:50
see

http://www.sqlis.com/sqlis/post/Looping-over-files-with-the-Foreach-Loop.aspx

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

Go to Top of Page
   

- Advertisement -