Compress File Task


Compress File Task shrinks the contents of a given input file (Text or JSON) into a .zip compression file format. This SQL Server Integration Services (SSIS) task does not automatically create a new .zipped output file at runtime, instead it requires you to specify an existing .zip file which is used during Compress File Task execution to store the compressed input Text or JSON file. For an example of how to configure and execute this SSIS task, see the Tutorial section.


As it will be demonstrated later, configuring Compress File Task requires you to specify two input parameters; an input file (Text or JSON) as well as a .zip file which will be used to store the compressed input file. Therefore in order to ensure that Compress File Task executes successfully, we need to ensure that we meet the specified prerequisites.


For the purposes of this tutorial, the JSON file that I will compress using Compress File Task is SST_FBSearch_20170401111854.json, shown in Figure 1.

JSON source file

Figure 1

I have also created a sample file (shown on Figure 2) which will be used to store the compressed JSON file.

Sample compressed JSON file

Figure 2

Configuring Compress File Task

Similarly to adding other SQL Server Integration Services (SSIS) tasks, the Compress File Task shown in Figure 3 can be added into the Control Flow pane in the following manner;

  1. Drag-and-drop the Compress File Task into the Control Flow, or
  2. Double clicking the Compress File Task
Compress File Task added onto the Control Flow pane

Figure 3

By default the Compress File Task will throw validation errors shown in Figure 4.

Compress File Task validation errors

Figure 4

To resolve the validation errors, we need to configure the Compress File Task by using its editor (Compress File Task Editor) shown in Figure 5.

Compress File Task Editor

Figure 5

There are two ways of configuring the textbox values in the editor:

Set Absolute Values

Providing absolute values for the two parameters refers to hardcoding the values into the two textboxes typing them in or by clicking the ellipsis buttons (…) to browse for required files, as shown in Figures 6.

Set Absolute Values

Figure 6

Dynamically Set Values using Expressions

Expressions reads data from package variables at runtime. To configure expressions, click the Ex button. This will open up a Choose Variable dialog box. You can then select the variable you want to use and click the OK button.

Choose Variable

Figure 7

Once you have clicked the OK button, you will be redirected back to the Compress File Task Editor with textboxes set to variable names as shown in Figure 8.

Set Values using Expressions

Figure 8

Executing Compress File Task

The execution of the Compress File Task is usually quick. Similarly to executing other SSIS tasks, the simplest way of executing Compress File Task is to right-click your mouse button, navigate to and click Execute Task option as shown in Figure 9.

Execute Compress File Task

Figure 9

If the configuration is done correctly, the Compress File Task execution should be successful as shown in Figure 10.

Compress File Task execution results

Figure 10

Additional information

Additional Informational Events

As the Compress File Task is being executed, it is important to take notes of two additional information events that will appear in the Execution Results tab in the designer. As indicated in Figure 11, these two informational events basically describe the parameter values that are being used in during task execution. This information could be useful during troubleshooting, especially in cases where Expressions are used to set parameter values.

Package execution results

Figure 11

Reuse Compressed Output File

The Compress File Task is designed to reuse the same compressed file specified in the Save As box. For instance, you can use the Compress File Task to compress Text1.txt into and later compress jsontest.json as again However, following the last change, when you open the, it will only contain the last file that was compressed – in this case, jsontest.json.