<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SSIS Script Task Archives | ZappySys Blog</title>
	<atom:link href="https://zappysys.com/blog/tag/ssis-script-task/feed/" rel="self" type="application/rss+xml" />
	<link>https://zappysys.com/blog/tag/ssis-script-task/</link>
	<description>SSIS / ODBC Drivers / API Connectors for JSON, XML, Azure, Amazon AWS, Salesforce, MongoDB and more</description>
	<lastBuildDate>Mon, 15 Jul 2019 13:50:58 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.4.4</generator>

<image>
	<url>https://zappysys.com/blog/wp-content/uploads/2023/01/cropped-zappysys-symbol-large-32x32.png</url>
	<title>SSIS Script Task Archives | ZappySys Blog</title>
	<link>https://zappysys.com/blog/tag/ssis-script-task/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Download latest File from FTP using SSIS (SFTP / FTPS)</title>
		<link>https://zappysys.com/blog/download-latest-file-from-ftp-using-ssis/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Sat, 01 Dec 2018 10:47:56 +0000</pubDate>
				<category><![CDATA[SSIS SFTP Task]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[ftps]]></category>
		<category><![CDATA[sftp]]></category>
		<category><![CDATA[SSIS Script Task]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=5490</guid>

					<description><![CDATA[<p>Introduction In this blog, we will learn how to Download Latest File from FTP using SSIS Secure FTP Task, We also learn how to connect with FTP/SFTP and also see how to Get Latest File list in ADO.net DataTable variable and How to sort ADO.net DataTable and get and set latest FTP File Path in a variable [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/download-latest-file-from-ftp-using-ssis/">Download latest File from FTP using SSIS (SFTP / FTPS)</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2><span id="Introduction">Introduction</span></h2>
<p><a href="https://zappysys.com/blog/wp-content/uploads/2018/12/download-latest-file-using-zs-sftp-task-1.png"><img decoding="async" class="alignleft wp-image-5517 size-thumbnail" src="https://zappysys.com/blog/wp-content/uploads/2018/12/download-latest-file-using-zs-sftp-task-1-150x150.png" alt="Download Latest File from FTP using SSIS" width="150" height="150" srcset="https://zappysys.com/blog/wp-content/uploads/2018/12/download-latest-file-using-zs-sftp-task-1-150x150.png 150w, https://zappysys.com/blog/wp-content/uploads/2018/12/download-latest-file-using-zs-sftp-task-1.png 293w" sizes="(max-width: 150px) 100vw, 150px" /></a></p>
<p>In this blog, we will learn how to <strong>Download Latest File from FTP using SSIS <a href="https://zappysys.com/products/ssis-powerpack/ssis-sftp-task-ftp-ftps/">Secure FTP Task</a></strong>, We also learn how to connect with FTP/SFTP and also see how to Get Latest File list in ADO.net DataTable variable and How to sort ADO.net DataTable and get and set latest FTP File Path in a variable using Script Task.</p>
<p>We also learn how to get and set variables and how to use it in SSIS Script Task and Secure FTP Task.</p>
<div style="clear: both;"><div class="content_block" id="custom_post_widget-2523"><h2><span id="Prerequisites">Prerequisites</span></h2>
Before we perform the steps listed in this article, you will need to make sure the following prerequisites are met:
<ol style="margin-left: 1.5em;">
 	<li><abbr title="SQL Server Integration Services">SSIS</abbr> designer installed. Sometimes it is referred to as <abbr title="Business Intelligence Development Studio">BIDS</abbr> or <abbr title="SQL Server Data Tools">SSDT</abbr> (<a href="https://docs.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt" target="_blank" rel="noopener">download it from the Microsoft site</a>).</li>
 	<li>Basic knowledge of SSIS package development using <em>Microsoft SQL Server Integration Services</em>.</li>
 	<li>Make sure <span style="text-decoration: underline;"><a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">ZappySys SSIS PowerPack</a></span> is installed (<a href="https://zappysys.com/products/ssis-powerpack/download/" target="_blank" rel="noopener">download it</a>, if you haven't already).</li>
 	<li>(<em>Optional step</em>)<em>.</em> <a href="https://zappysys.zendesk.com/hc/en-us/articles/360035974593" target="_blank" rel="noopener">Read this article</a>, if you are planning to deploy packages to a server and schedule their execution later.</li>
</ol></div></div>
<h2></h2>
<h2><span id="Requirements">Requirements</span></h2>
<ol>
<li>First, you will need to have SSIS installed</li>
<li>Also, make sure to have SSDT</li>
<li>Make sure to have installed <a href="https://zappysys.com/products/ssis-powerpack/">ZappySys SSIS PowerPack</a>.</li>
</ol>
<h2><span id="Whats_is_FTP_FTPS_SFTP_FTPSSL">What is FTP, FTPS, SFTP, FTP/SSL?</span></h2>
<p>Many people still have confusion over various protocols around FTP terminology. Most common terms you hear are as below.</p>
<ul>
<li>FTP</li>
<li>Classic FTP</li>
<li>Secure FTP</li>
<li>SFTP</li>
<li>FTPS</li>
<li>FTP/SSL</li>
<li>FTP over SSL</li>
<li>FTP Over SSH</li>
</ul>
<p>You must be overwhelmed by now? So are they all same or different? See below for quick clarification in nutshell.</p>
<p>Mainly there are 2 protocols for FTP and yes they are very different but still used to do Files Transfer to/from the remote server.</p>
<ol>
<li><strong>Classic FTP</strong> – sometimes referred as just <strong>FTP</strong> (Typically server runs on Port 21)</li>
<li><strong>SFTP</strong> – Sometimes referred as <strong>Secure FTP</strong> or <strong>FTP over SSH</strong> (Typically server runs on Port 22)</li>
</ol>
<p>So in short SFTP is not the same as the Classic FTP protocol. SFTP is more secure because traffic is always encrypted. On the other hand, Classic FTP is not encrypted by default but you can use <strong>FTP over SSL</strong> to request encrypted traffic in classic FTP. <strong>FTP over SSL</strong> also referred as <strong>FTPS or FTP/SSL</strong>.</p>
<h2></h2>
<h2>Getting Started</h2>
<p>In order to start, we will show several examples. ZappySys includes an SSIS &#8211; <a href="https://zappysys.com/products/ssis-powerpack/ssis-sftp-task-ftp-ftps/">Secure FTP Task</a> that will help you Download Latest File From FTP/SFTP, get file list in ADO.net DataTable variable and do many more actions using SSIS Script Task.</p>
<p>In this example, we will show 3 examples.</p>
<ol>
<li>First, we will show how to get FTP File List as ADO.net DataTable in a variable using <a href="https://zappysys.com/products/ssis-powerpack/ssis-sftp-task-ftp-ftps/"><strong>SSIS &#8211; Secure FTP Task</strong></a>.</li>
<li>Secondly, we will show how to sort ADO.net DataTable and get latest FTP File Path in a variable using <strong>Script Task</strong>.</li>
<li>Third, we will Download Latest File from FTP using SSIS <strong><a href="https://zappysys.com/products/ssis-powerpack/ssis-sftp-task-ftp-ftps/">Secure FTP Task</a> </strong>using that latest file path variable.</li>
</ol>
<h3><span id="1_Example_to_get_values_from_JSON_into_variables" style="font-size: 12pt;">Get FTP File List as ADO.net DataTable in a variable using SSIS Secure FTP Task</span></h3>
<p>Follow these steps to accomplish the task:</p>
<ol>
<li>Drag and drop <strong>Secure FTP Task</strong> the design panel and rename it as &#8220;Get File List as ADOnet DataTable&#8221; if you want to.</li>
</ol>
<div id="attachment_2780" class="wp-caption aligncenter">
<div id="attachment_5494" style="width: 719px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/12/drag-drop-ZS-SFTP-Task.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-5494" class="wp-image-5494 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/12/drag-drop-ZS-SFTP-Task.png" alt="ADD SSIS - ZS SECURE FTP TASK" width="709" height="460" srcset="https://zappysys.com/blog/wp-content/uploads/2018/12/drag-drop-ZS-SFTP-Task.png 709w, https://zappysys.com/blog/wp-content/uploads/2018/12/drag-drop-ZS-SFTP-Task-300x195.png 300w" sizes="(max-width: 709px) 100vw, 709px" /></a><p id="caption-attachment-5494" class="wp-caption-text">ADD SSIS &#8211; ZS SECURE FTP TASK</p></div>
</div>
<div></div>
<div></div>
<div style="padding-left: 30px;">2. Now Edit the FTP Task from the package design panel to Connect with your FTP/SFTP. Follow the steps mentioned in the below screen.</div>
<div></div>
<div style="padding-left: 60px;">
<div id="attachment_5495" style="width: 1260px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/12/connect-sftp-server-and-test-connection.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-5495" class="wp-image-5495 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/12/connect-sftp-server-and-test-connection.png" alt="Connect with FTP/SFTP using SSIS" width="1250" height="704" srcset="https://zappysys.com/blog/wp-content/uploads/2018/12/connect-sftp-server-and-test-connection.png 1250w, https://zappysys.com/blog/wp-content/uploads/2018/12/connect-sftp-server-and-test-connection-300x169.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/12/connect-sftp-server-and-test-connection-768x433.png 768w, https://zappysys.com/blog/wp-content/uploads/2018/12/connect-sftp-server-and-test-connection-1024x577.png 1024w" sizes="(max-width: 1250px) 100vw, 1250px" /></a><p id="caption-attachment-5495" class="wp-caption-text">Connect with FTP/SFTP</p></div>
</div>
<div></div>
<div style="padding-left: 30px;">3. After successfully connected with FTP/SFTP we have to enter FTP path from where we have to get the file list and set it into result variable.</div>
<div></div>
<div style="padding-left: 60px;">
<div id="attachment_5497" style="width: 1156px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/12/set-ftp-path-and-result-variable-1.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-5497" class="wp-image-5497 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/12/set-ftp-path-and-result-variable-1.png" alt="SSIS - Get Latest file list from FTP to ADO.net table in the variable" width="1146" height="665" srcset="https://zappysys.com/blog/wp-content/uploads/2018/12/set-ftp-path-and-result-variable-1.png 1146w, https://zappysys.com/blog/wp-content/uploads/2018/12/set-ftp-path-and-result-variable-1-300x174.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/12/set-ftp-path-and-result-variable-1-768x446.png 768w, https://zappysys.com/blog/wp-content/uploads/2018/12/set-ftp-path-and-result-variable-1-1024x594.png 1024w" sizes="(max-width: 1146px) 100vw, 1146px" /></a><p id="caption-attachment-5497" class="wp-caption-text">Get Latest file list from FTP to ADO.net table in a variable</p></div>
</div>
<div></div>
<div></div>
<div style="padding-left: 30px;">4. Now let&#8217;s check what ADO.net DataTable columns name and ordinal.</div>
<div></div>
<div style="padding-left: 60px;">
<div id="attachment_5498" style="width: 1271px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/12/see-adonet-data-table-columns-list.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-5498" class="wp-image-5498 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/12/see-adonet-data-table-columns-list.png" alt="SSIS - Set Latest ADO.net DataTable Variable" width="1261" height="673" srcset="https://zappysys.com/blog/wp-content/uploads/2018/12/see-adonet-data-table-columns-list.png 1261w, https://zappysys.com/blog/wp-content/uploads/2018/12/see-adonet-data-table-columns-list-300x160.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/12/see-adonet-data-table-columns-list-768x410.png 768w, https://zappysys.com/blog/wp-content/uploads/2018/12/see-adonet-data-table-columns-list-1024x547.png 1024w" sizes="(max-width: 1261px) 100vw, 1261px" /></a><p id="caption-attachment-5498" class="wp-caption-text">Set Latest ADO.net DataTable Variable</p></div>
</div>
<div></div>
<div style="padding-left: 60px;">5. That&#8217;s it we have successfully completed our first task. Let&#8217;s move on next step.</div>
<div></div>
<div>
<h3><span id="1_Example_to_get_values_from_JSON_into_variables" style="font-size: 12pt;">Get latest FTP File Path in a variable using Script Task</span></h3>
<p>Follow these steps to accomplish the task:</p>
<p style="padding-left: 30px;">1. Drag and drop <strong>SSIS Script Task</strong> the design panel and link it with the ZS SFTP Task.</p>
<div id="attachment_5499" style="width: 259px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/12/ssis-add-script-task.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-5499" class="wp-image-5499 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/12/ssis-add-script-task.png" alt="Add SSIS - Script Task" width="249" height="145" /></a><p id="caption-attachment-5499" class="wp-caption-text">Add SSIS &#8211; Script Task</p></div>
<p>&nbsp;</p>
<p style="padding-left: 30px;">2. Before proceeding with Script Task let&#8217;s add one new SSIS variables first that will store the Latest FTP File Path.</p>
</div>
<div id="attachment_5501" style="width: 1332px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/12/add-new-latest-file-variable-in-package.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-5501" class="wp-image-5501 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/12/add-new-latest-file-variable-in-package.png" alt="Add SSIS Latest File Variable" width="1322" height="754" srcset="https://zappysys.com/blog/wp-content/uploads/2018/12/add-new-latest-file-variable-in-package.png 1322w, https://zappysys.com/blog/wp-content/uploads/2018/12/add-new-latest-file-variable-in-package-300x171.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/12/add-new-latest-file-variable-in-package-768x438.png 768w, https://zappysys.com/blog/wp-content/uploads/2018/12/add-new-latest-file-variable-in-package-1024x584.png 1024w" sizes="(max-width: 1322px) 100vw, 1322px" /></a><p id="caption-attachment-5501" class="wp-caption-text">Add Latest File Variable</p></div>
<p>&nbsp;</p>
<p style="padding-left: 30px;">3. Now edit Script Task and add User::v_dtFileLists and User::v_LatestFilePath to ReadOnly/ReadWrite variable lists:<br />
<img loading="lazy" decoding="async" class="alignnone size-full wp-image-7479" src="https://zappysys.com/blog/wp-content/uploads/2018/12/download-latest-file-from-ftp-configure-script-task.png" alt="" width="737" height="320" srcset="https://zappysys.com/blog/wp-content/uploads/2018/12/download-latest-file-from-ftp-configure-script-task.png 737w, https://zappysys.com/blog/wp-content/uploads/2018/12/download-latest-file-from-ftp-configure-script-task-300x130.png 300w" sizes="(max-width: 737px) 100vw, 737px" /></p>
<p style="padding-left: 30px;">4. Then proceed and press &#8220;Edit Script&#8221; button to edit the code the Script Task &#8212; it will open the &#8220;ScriptMain.cs&#8221; C# file for you in new VS Project. And Write The Following Code in it.</p>
<pre class="crayon-plain-tag">DataTable dt = (DataTable)Dts.Variables["User::v_dtFileLists"].Value;

DataView dv = dt.DefaultView;
dv.Sort = "CreationTime desc";
DataTable sortedDT = dv.ToTable();
if (sortedDT.Rows.Count &gt; 0)
{
	Dts.Variables["User::v_LatestFilePath"].Value = sortedDT.Rows[0][0].ToString();
}
dt=null;
dv = null;
sortedDT = null;</pre>
<div id="attachment_5502" style="width: 893px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/12/sort-data-table-and-get-latest-file-path.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-5502" class="wp-image-5502 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/12/sort-data-table-and-get-latest-file-path.png" alt="SSIS - Get Latest File Path in Variable" width="883" height="720" srcset="https://zappysys.com/blog/wp-content/uploads/2018/12/sort-data-table-and-get-latest-file-path.png 883w, https://zappysys.com/blog/wp-content/uploads/2018/12/sort-data-table-and-get-latest-file-path-300x245.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/12/sort-data-table-and-get-latest-file-path-768x626.png 768w" sizes="(max-width: 883px) 100vw, 883px" /></a><p id="caption-attachment-5502" class="wp-caption-text">Get Latest File Path in Variable</p></div>
<p>&nbsp;</p>
<p style="padding-left: 30px;">5. Click Ok In &#8220;Script Task&#8221; And it will save and close the &#8220;ScriptMain.cs&#8221; Task.</p>
<p style="padding-left: 30px;">6. That&#8217;s it we have successfully completed our second task. Let&#8217;s move on next step.</p>
<h3><span style="font-size: 12pt;">Download Latest File from FTP using the latest file path variable</span></h3>
<p>Follow these steps to accomplish the task:</p>
<p style="padding-left: 30px;">1. Drag and drop <strong>ZS</strong> <strong>Secure FTP Task</strong> the design panel and link it with Script Task.</p>
<div id="attachment_5506" style="width: 258px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/12/blob-dlf-add-SFTP.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-5506" class="wp-image-5506 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/12/blob-dlf-add-SFTP.png" alt="Add SSIS - ZS Secure FTP Task" width="248" height="220" /></a><p id="caption-attachment-5506" class="wp-caption-text">Add SSIS &#8211; ZS Secure FTP Task</p></div>
<p>&nbsp;</p>
<p style="padding-left: 30px;">2. Let&#8217;s use that latest file variable and FTP Connection to download the latest file in the local folder. Follow the mentioned steps of the below screen.</p>
<div id="attachment_5507" style="width: 684px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/12/blob-dlf-download-latestfile-using-variable-in-SFTP.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-5507" class="wp-image-5507 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/12/blob-dlf-download-latestfile-using-variable-in-SFTP.png" alt="Download Latest File using variable using SSIS -Secure FTP Task" width="674" height="655" srcset="https://zappysys.com/blog/wp-content/uploads/2018/12/blob-dlf-download-latestfile-using-variable-in-SFTP.png 674w, https://zappysys.com/blog/wp-content/uploads/2018/12/blob-dlf-download-latestfile-using-variable-in-SFTP-300x292.png 300w" sizes="(max-width: 674px) 100vw, 674px" /></a><p id="caption-attachment-5507" class="wp-caption-text">Download Latest File using variable using SSIS -Secure FTP Task</p></div>
<p style="padding-left: 30px;">3. Click OK to close Secure FTP TASK UI.</p>
<p>Finally, run the package and you will be able to see the latest file downloaded on your local folder from the FTP/SFTP.</p>
<h2><span id="Conclusion">Conclusion</span></h2>
<p>To conclude, we can say that working with FTP/SFTP is now very simple. In this article, we looked at SSIS SFTP task examples on how to Download latest File from FTP using SSIS in the local folder. We also learned how to Sort ADO.net DataTable and Set latest file path in the variable using <strong>SSIS Script Task</strong>.  We used variables, expressions, and SSIS Script Task. If you liked the tasks you can start using them by downloading SSIS PowerPack from our <a href="https://zappysys.com/products/ssis-powerpack/">website here</a>.</p>
<h2><span id="References">References</span></h2>
<ul>
<li><a href="https://zappysys.com/products/ssis-powerpack/">About SSIS PowerPack</a></li>
<li><a href="https://zappysys.com/products/ssis-powerpack/ssis-sftp-task-ftp-ftps/">About Secure FTP Task</a></li>
<li><a href="https://docs.microsoft.com/en-us/sql/integration-services/control-flow/script-task?view=sql-server-2017">SISS Script Task</a></li>
<li><a href="https://docs.microsoft.com/en-us/sql/integration-services/integration-services-ssis-variables?view=sql-server-2017">About SSIS Variables</a></li>
</ul>
<p>&nbsp;</p>
<p>The post <a href="https://zappysys.com/blog/download-latest-file-from-ftp-using-ssis/">Download latest File from FTP using SSIS (SFTP / FTPS)</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
