Skip to main content

Software Development

How to create zip file which contains single text file with a fixed threshold in SSIS.

Coding On Laptop 1200x.progressive

What is SSIS?

SQL Server Integration Service (SSIS) is a component of the Microsoft SQL Server database software that can be used to execute a wide range of data migration tasks. The SSIS ETL tool Extracts data from different sources and transforms that data according to user requirements. And then loads data into various destinations. SSIS is a fast & flexible data warehousing tool used for data extraction, loading and transformation like cleaning, aggregating, merging data, etc.

R

Following are components of SSIS that we need to create zip file-

Execute SQL Task: As its name suggests, it will execute a SQL statement against a relational database.

Data Flow Task: This task can read data from one or more sources. Transform the data when it is in the memory and write it out against one or more destinations.

File System Task: It performs manipulations in the file system. Like moving, renaming, deleting files, and creating directories

Script Task: This is a blank task. You can write NET code which performs any task; you want to perform.

Containers-

Sequence Container: Allows you to organize subsidiary tasks by grouping them and allows you to you apply transactions or assign logging to the container.

For loop container: Provides the same functionality as the sequence Container except that it also lets you run the tasks multiple times. However, it is based on an evaluation condition, like a looping from 1 to 100.

For each Loop Container: It also allows looping. But the difference that instead of using a condition expression, loop s done over a set of objects, likes files in a folder.

Threshold: A “threshold” is not a maximum but a point at which something changes. For example, in this package, “There is a text file which allows 20 rows, but if your count reaches the THRESHOLD then it will create the new zip file.”

Let’s see how we can create zip file which contains single text file with a fixed threshold in SSIS.

Following are the variables which we need to implement the same.

1

Step 1- Drag and drop the Sequence Container and inside the sequence container drag the for each loop container and configure it as below-

2

Step 2- Now, Add the File system task inside the for each loop container to delete the existing text files.

3

Step 3- Next, drag the Execute SQL Task and configure the SQL statement for each record count by executing the procedure and configure the parameter mapping and result set.

4

5

6

Step 4- Now, drag the For-loop container and configure it as below.

7

Step 5- Add the data flow task the data will flow from OLE DB source, record count and Flat File destination inside the for-loop container.

8

Step 6- Finally, add script task to convert text file into zip file and to move that zip file with fixed threshold in archive folder in the for loop container and configure it as below.

9

We have 40 records in our source, and we have set the threshold as 20 and it has separated 20 records in single text file and 20 in another file.

10

Here we have successfully archived the zip file which contains single text file with a fixed threshold in SSIS.

For more such blogs click here

Thanks for reading!! Hope you enjoyed reading this blog.

Thoughts on “How to create zip file which contains single text file with a fixed threshold in SSIS.”

  1. Gaurav Chawre

    Very nicely explained.
    Actually looking for this kind of detailed and easy to understand explanation.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Saloni Kadu

Saloni Kadu works at Perficient as an Associate Technical Consultant. She has over 10 months of experience in ETL tools -SSIS and SQL. She also has a good knowledge of Python, SSRS and Snowflake.

More from this Author

Follow Us
TwitterLinkedinFacebookYoutubeInstagram