Escolar Documentos
Profissional Documentos
Cultura Documentos
Exchange
By: Arshad Ali | Read Comments (17) | Related Tips: More > Integration Services Control Flow
Transformations
Problem
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
An FTP (File Transfer Protocol) server is often used for data exchanges in many data integration scenarios. SSIS includes
an FTP task to download and upload data files to and from an FTP location, but how does this work and how can we
configure it for data file downloads and uploads?
Solution
When data integration system or ETL processes can't connect directly to the data source system, an FTP server can be
used as a temporary storage location for data exchange. Source systems can upload data to an FTP server and then the
data integration system can download the data from the FTP server and import the data into the database.
SSIS being one of the leading ETL tools in the market includes an FTP task for working with an FTP server. Downloading
data files from an FTP server to the local machine and other tasks can be used to import the data from the locally
downloaded data files to the database/data warehouse. Not only does the FTP Task allow downloading of the data files,
but there are a host of other operations that can be performed with this task as mentioned below:
Operation Description
Send files Used for uploading files from the local machine to the FTP server
Receive files Used for downloading files from the FTP server to the local machine
There are different ways to connect to an FTP Server for data verification and one of the easiest ways is to use
Windows Explorer. Just specify the FTP Server name with FTP protocol as shown below and hit <Enter>.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Latest from MSSQLTips
SQL Server Performance
Considerations - Fetching Rows One
This will bring up a screen as shown below. Here we need to specify the credentials to connect to the FTP Server or
By One or All At Once
choose to log on anonymously if the FTP Server allows anonymous access.
Power BI Desktop Custom
Visualization
Next click on the Log On button to log onto the specified FTP Server with the specified credentials. Based on
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
permissions, it will display folders and files similarly to what's shown below:
In order to connect to an FTP Server, we first need to create an FTP connection manager which encapsulates
information needed to connect to the FTP Server and the FTP task that uses that information at run time to connect to
the server. In order to create a FTP connection manager create a new package and right click on the Connection
Managers pane on the bottom and then select FTP as the connection manager type from the dialog box as shown
below:
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Clicking on the Add button on the above dialog box will bring up an FTP Connection Manager Editor to specify the
different information which will be used to connect to the FTP Server. For example, the FTP Server name, port,
credentials to connect to the FTP Server, etc...
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Now you can drag an FTP Task from the SSIS Toolbox to the control flow, which will look similar to this:
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Double click on the FTP task to change its properties in the Editor. The editor has 3 pages. On the General page we
need to select the FTP connection manager that we created above for connecting to the FTP Server and then specify
an appropriate name and description for the component as shown below:
On the FTP Transfer page, we first need to select the operation that we want to perform (more about these different
operations can be found in the beginning of this tip) with this FTP task based on the Local Parameters and Remote
Parameters options will appear or disappear. For example, when we select "Receive files" as the operation type then
both Local Parameters and Remote Parameters options will appear, but if I select the "Create remote directory"
option then only the Remote Parameters option will appear.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
For this example I want to download a specific file from the FTP Server so I will chose "Receive files" as the operation
type and then specify the remote parameters like location and name of the file to be downloaded and the local
parameters like local machine folder where the downloaded file will be saved. Here, I can either specify hard-coded
values for these parameters or the values can come from SSIS package variables making this process more dynamic.
As you might have noticed, we can select only one operation type for each FTP task and if we want to perform multiple
operations we need to use multiple FTP tasks, one for each operation. Now if I execute the package we can see the file
from the FTP Server getting downloaded and written to the folder that we specified. After the file has been downloaded I
can then use a data flow task to load data from the locally downloaded file to the database.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Downloading Multiple Files using a Wild Card Character
In the above example, I simply downloaded one file from the FTP Server to the local machine. But what if I want to
download or upload all the text files or all the XML files in one go. Well in that scenario, we can use a wild card
character. For example, as you can see below I want to download all text files from the specified FTP Server location to
the local machine and hence I specified "*.txt" for the file name.
Now the above specified wild card character will download all the text files to the local machine from the FTP Server. To
load each of these files to the database I can use a ForEach Loop container in SSIS as shown below.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
We can use the ForEach Loop Container with a ForEach File Enumerator and process all the data files from the
locally downloaded folder; in other words, process each data file one at a time in a loop.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
The FTP Task in SSIS does not support SFTP (Secured FTP), but there is a task available at codeplex which can be used
for this scenario.
Next Steps
Review Get List of Files from an FTP Server in SQL Server Integration Services
Review SSIS SFTP Task Control Flow Component on codeplex
Review other SSIS control flow component tips
Learn More
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Post a comment or let the author know this tip helped you.
All comments are reviewed, so stay on subject or we may delete your comment.
Paragraph
*** NO TE *** - If you want to include code from SQ L Se rve r Manage m e nt Studio (SSMS) in your post, ple ase copy the code from SSMS and
paste the code into a te x t e ditor lik e Note Pad be fore copying the code be low to re m ove the SSMS form atting.
Note: your email address is not published. Required fields are marked with an asterisk (*)
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
*Enter Code Save Comment
I have issue. When I done conteiner I received result: 6000 records from only 1 file. But I had above 60 files and 100
records in each. I recived all records from 1 file dublicated as many times as I have files. Pease help
Thursday, October 01, 2015 - 2:04:19 PM - Mahfooz Elahi Read The Tip
I am able to do the FTP through MS Visual Studio but when I try to schedule it as part of a .dtsx package it gives me
an error saying "Password was not allowed". I understand that the XML file does not store the password. I am not sure
how to solve this issue. Any help will be appreciated.
Please give me solution for set encrption type in FTP Task in ssis.
Arshad, this is very helpful in automating one process that I have been spending a lot of time on. Can you please help
me with the next steps, i.e., the Data Flow task? Now that I have 5 CSV files in my local system, how do I go about
loading them to SQL tables.
Monday, October 06, 2014 - 2:35:15 PM - Arif Hassan Read The Tip
How do you set up ssis ftp package into ssms job, I am getting error message, only way I can do is to use encrypted
password. Is there any work around?
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Tuesday, September 30, 2014 - 3:36:39 PM - Golam Kabir Read The Tip
Thank you
I can't seem to get the FTP connection manager to save the password. How do I get the ftp password saved?
Tuesday, April 15, 2014 - 7:19:27 PM - Jay Patel Read The Tip
I am trying to ftp file(s) from and to AS400 using ssis 2005 sql server. The ssis runs successfully but files are not
sending or receiving. Any suggestions.
Tuesday, March 18, 2014 - 1:51:06 PM - Matt Massey Read The Tip
Great write up! This really helped me out as today was my first time setting up an FTP Task. Thanks!
Thursday, February 13, 2014 - 2:21:38 PM - Ravi Ramaswamy Read The Tip
Arshad,
Thanks,
Ravi Ramaswamy
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
FTP Task Editor=>
IsLocalPathVarible:- True
Local Varible :- User::Final
Remote Parameter
IsRemotePathVarible :-False
But [Connection manager "FTP Connection Manager"] Error: An error occurred in the requested FTP operation. Detailed
error description: The filename, directory name, or volume label syntax is incorrect. . e SSMS formatting.
http://ssissftp.codeplex.com/documentation
http://geekswithblogs.net/NibblesAndBits/archive/2012/04/09/adding-a-dll-to-the-gac-in-windows-7.aspx
Hi,
Greate article, I was wonder if is possible to connect to a SFTP Server using FTP Task?
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Thanks
Sunday, May 12, 2013 - 10:07:03 AM - Arshad Ali Read The Tip
Hi Yang, good to know it was helpful to you, thanks for your feedback.
Hi Chandu, yes you can use wildcard characters to download or upload files with specific naming pattern.
Dear Arshad,
It is really helpful!
Even yesterday I was struggling with the FTP file downloading and loading into database. Now it is all solved with your
article!
Thanks!
Yang
Arshad,
Is it possible to place a dynamic criteria for wildcharecters for receiving files from a ftp folder ,like a specific date
based expression criteria such as last day of evefry month file from a list of files with date stamp.
Many Thanks
Chandu
How to find & fix SQL Server performance issues. 26 free monitoring tips for DBAs. Sign up now
Solving SQL Server problems for millions of DBAs and Devs since 2006. Join now.
Free SQL Server Tutorials - Stored Procedures, Performance Monitoring, Query Plans, SSIS and more
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com