Thursday, January 15, 2009

How to Unzip a File in SSIS?



For SSIS packages, most of the times you will get zip, rar or tar etc files to extract them during the extraction operation in SSIS. Let us see how we can do this from SSIS.
You can use Execute Process Task in Control Flow task. Drag and drop an Execute Process task to the control flow and configure as following image.

In this, you need to perform three configurations.
1. Executable: This is the path of the application you are going to use. This specific example has used Winrar.
2. Arguments: in this you need to supply the arguments to extract the zipped files. In the particular example e stands for Extract files to current directory. Then the full path name of the zipped file. –o+ is a parameter to say overwrite files if existing. This parameter will hide the conformation dialog which will come in case of an existing file.
3. Working Directory: This is the current directory for the process. In the given example test1.rar will be extract to the directory given in the Working Directory attribute.
However, Most of the time there will be several zip file to extract and path may not be defined this clearly. For this you can you for each container and include process task inside it like following image.

In the for each loop container, enumerator is Foreach File Enumerator which is the default enumerator. In the Execute process task all the configuration are same as above but with in expressions, arguments were set to "e " +@[User::currentFile] + " -o+"
Download the sample SSIS package
here.

No comments:

Post a Comment