Introduction
This article provides a concise guide on how to download a file from a URL and load it into a SQL table using SSIS, covering the setup, configuration, and execution of the necessary steps to streamline your data workflows.
Solution
In this article, we demonstrate how to automate the process of loading files from URLs stored in CSV files into an SQL table using SQL Server Integration Services (SSIS). We will guide you through reading the URLs from the CSV file using CSV Source, read/downloading the files using a Web API Destination, and finally loading the file data into a SQL table with a VARBINARY
datatype column using an Upsert Destination.
If you have file URLs in any other source, you can read the file URL from there using the desired source component.
We also have an article that demonstrates how to extract image URLs from a web page and download the images. You can read it How to download images from a web page using SSIS.
Step-by-Step Guide
Let’s jump right in, step by step, as we learn how to load a file from a URL to an SQL Table using SSIS.
-
Firstly, You need to Download and Install SSIS ZappySys PowerPack.
-
Once you have finished the first step, Open Visual Studio and Create a New SSIS Package Project.
-
Now, Drag and Drop SSIS Data Flow Task from SSIS Toolbox. And double click on the DataFlow task to see DataFlow designer surface.
-
From the SSIS toolbox, drag and drop CSV Source on the dataflow designer surface.
-
Double click CSV Source and configure it like this:
- Set the CSV File Path: In this case, use
FileURLs.csv
. - Select the Desired Column Separator Choose the appropriate column separator.
- Check “First Row Has Column Headers”: Ensure this option is selected.
- Preview the CSV File Data: Click on “Preview” to view the data.
- Close the CSV Source: Click “OK” to close the CSV Source.
- Set the CSV File Path: In this case, use
-
Below the CSV Source, drag and drop the Web API Destination. Configure a new HTTP Connection by setting the dummy Web URL to
https://
then click OK.
-
Set the CSV Source
FileURL
column as the input column for the URL. ChooseGET
as the HTTP Request Method, checkmark “Treat Response as Binary Data”, and then click “OK”.
-
Now let’s load the file data and the file URL into the SQL Table using Upsert Destination:
Sample SQL Table:CREATE TABLE "tblFiles" ( "FileUrl" nvarchar(248), "FileData" varbinary(max), )
-
Next, drag and drop the Upsert Destination. Begin by configuring a New ADO.NET SQL Connection for your SQL database.
-
Select or create a new SQL table, map the source columns, choose the key column (in this case, FileURL), and click “OK”.
-
That’s it! Run the SSIS package, and it will read the URL from the CSV, download the file using the Web API destination, and load the data into the SQL table using the Upsert destination.
Related Articles
- How to download file from URL using SSIS
- How to download files from OneDrive using SSIS
- How to download files from SharePoint Online using SSIS
- How to download files from Google Drive using SSIS
- How to download images from a web page using SSIS
Conclusion
This comprehensive guide should assist you in reading/downloading a file from a URL and loading it into an SQL table using ZappySys components in your SSIS packages. For further assistance, please contact our support team via chat on our website.