Zip Task

SQL Server 2005, 2008, 2008R2, 2012, 2014

SQL Server 2005, 2008, 2008R2, 2012, 2014

All Downloads ----- Questions?

Overview

The Zip Task is an SSIS Control Flow task for compression and decompression of Zip, GZip, BZip2, Unix (rfc1950) and Tar archives.

Tip: If you want to uncompress files created by the standard Unix "compress" utility, use this script.

Demonstration

Demonstration VideoDemonstration Video

Setup

Use the General page of the Zip Task Editor dialog to configure the parameters needed for archive compression and decompression.

Parameters

Name

Specify the task name.

Description

Specify the task description.

Action

Specify the task action. This parameter has the options listed in the following table.

Option Automation Description
Compress 1

Compress files into an archive.

IsSourceVariable, Source, SourceVariable specify input files.
Starting from (1.3 SR-3) you can enter multiple source specifications, each one separated with a vertical bar (|).

IsTargetVariable, Target, TargetVariable specify the output archive destination.

Decompress 0

Decompress files from an archive.

IsSourceVariable, Source, SourceVariable specify the input archive file.

IsTargetVariable, Target, TargetVariable specify the output files destination.

CompressionType

Specify the type of compression or decompression. This parameter has the options listed in the following table.

Option Automation Description
Zip 0 Type of archive is Zip.
Tar 1 Type of archive is Tar.
File 2 Type of archive is a single file (1.3).
CompressionLevel

Visible only when the specified action is Compress.

When the Zip compression type is selected, this parameter specifies the level of compression - Maximum (4), Maximum (3), Maximum (2), Maximum (1), Maximum (enhanced deflate), Maximum (portable), Normal, Fast, Super fast, None.

When the Tar compression type is selected, this parameter specifies the type of compressor used - GZip, BZip2, Unix, None.

Password

Visible only when the specified compression type is Zip. Specify the archive encryption password. Remember to specify the EncryptionType you want to use.

EncryptionType (1.5 SR-2)

Specify the ZIP encryption type. You must also specify a Password in order for the task to perform the encryption. This parameter has the options listed in the following table.

Option Description
Zip2 Use regular ZIP 2.0 encryption.
AES128 Use strong AES encryption with a 128-bit key.
AES256 Use stronger AES encryption with a 256-bit key.
IsSourceVariable

Indicate whether or not the source is stored in a variable. This parameter has the options listed in the following table.

Option Description
True The source is stored in a variable. Selecting this option displays the dynamic parameter SourceVariable.
False The source is specified in a File connection manager. Selecting this option displays the dynamic parameter Source.
Source

Select an existing File connection manager, or you may click <New connection...> to create a new connection manager.

Related topics: File Connection Manager

SourceVariable

Select an existing user-defined variable, or you may click <New variable...> to create a new variable.

Related Topics: Integration Services Variables, Add Variable

RemoveSource

Visible only when the specified action is Compress. Specify this parameter if you want the task to remove the source files after compression is complete.

IncludeSubfolders

Visible only when the specified action is Compress. Specify this parameter if you want the task to recursively include all sub-files and sub-folders.

IsTargetVariable

Indicate whether or not the target is stored in a variable. This parameter has the options listed in the following table.

Option Description
True The target is stored in a variable. Selecting this option displays the dynamic parameter TargetVariable.
False The target is specified in a File connection manager. Selecting this option displays the dynamic parameter Target.
Target

Select an existing File connection manager, or you may click <New connection...> to create a new connection manager.

Related topics: File Connection Manager

TargetVariable

Select an existing user-defined variable, or you may click <New variable...> to create a new variable.

Related Topics: Integration Services Variables, Add Variable

OverwriteExisting

Visible only when the specified action is Decompress. Specify this parameter if you want the task to overwrite the existing target files.

ExtractFullPath (1.5)

Visible only when the specified action is Decompress and CompressionType is Zip or Tar. Specify this parameter if you want the task to extract the files in the path stored in the source package.

How to compress multiple files

You can specify multiple source files for compression in two different ways:

  • Specify source file(s) via File Connection Manager.
  • Specify source file(s) via package variable.

The first option is a little bit tricky. If you provide an existing file with a wildcard specification, the dialog will not validate it. To make this work, create a File Connection Manager which points at the existing file. After you close the dialog, right-click on the just created connection manager and click the Properties menu. Set the ConnectionString property to the required wildcard specification. The Zip Task will now compress all files which match the specified wildcard.

How to append files to existing archive

Zip Task doesn't support appending files to existing archive. Use the workaround below to accomplish your goal:

  • Setup Zip Task to extract the existing archive to a folder.
  • Copy one or more files you want appended in the folder you have extracted.
  • Compress the folder using Zip Task into a new archive.
  • Overwrite the original archive with the new archive.

Samples

  • For a sample showing how to setup a Zip Task to stream data without intermediate storage, see this package.
  • For a sample showing how to iterate with a for-each container using a variable, see this package. You may also check this forum post.