Skip Navigation LinksHome > View Post

SSIS Compress File Task now with added decompression

IMPORTANT This post and the corresponding code was created some years ago. I've hardly worked with SSIS since and so don't plan to update the code to support the latest versions of SQL Server. The component and source were designed for SQL Server 2005 and will not work in SQL Server 2008 or later. You can take the code and change it at your will (I hear it's a simple fix). I considered pulling the posts altogether but a number of people have found value in these ideas even if they have to modify the code.

Due to public demand (ok, two people) I've added decompression support to the original SSIS Compress File Task. It works almost exactly the same but now has a simple CompressionMode property:

Compress File Task UI v1.1

Adding properties to existing tasks doesn't work, so I've had to create a new version (1.1) so you'll need to move wholesale to 1.1. Apologies for the lack of a more graceful upgrade experience for anybody using version 1.0. A big thanks goes to Eric Belfort who was one of the two who enquired about a decompression option and helped out with the testing of this new version.

UPDATE - Thanks to Davide for pointing out the dodgy link to the original 1.0 version, which has now been fixed.

Tags: SQL SSIS

 
Josh Post By Josh Twist
1:11 PM
14 Nov 2006

» Next Post: Setting up two web sites in IIS7
« Previous Post: Nice usage of AJAX

Comments are closed for this post.

Posted by Davide @ 16 Nov 2006 5:26 PM
Josh, your Compress File Task is just GREAT! Thank you.
I downloaded the MSI found at here:
http://www.thejoyofcode.com/uploads/compressFileTask_msi.zip
and I installed it fine, but it is version 1.0.
Where can I find version 1.1 with the decompression?
Thank you,

Davide

Posted by Josh @ 17 Nov 2006 12:09 AM
Thanks Davide - I've uploaded the correct version and fixed the link to the source. I wasn't having a good day was I?

Posted by Davide @ 21 Nov 2006 10:02 AM
Josh,
Thank you very much for the updated link and most of all for the excellent SSIS Task.

Posted by Alistair @ 30 May 2007 7:42 AM
I tried using your task to unZip a ZIP file and I get the following error.
"Block length does not match with its complement. "
Any suggestions?

Posted by Josh @ 31 May 2007 2:08 AM
Hi Alistair,

The compression algorithms supported are GZIP and DEFLATE only. Zip is a different format. Try using WinZip (or equivalent) via a command line.

Posted by Mike @ 26 Jun 2007 5:33 PM
Great stuff! Any chance you'll include support for Zip format files in the future?

Posted by Josh @ 27 Jun 2007 3:49 AM
Hi Mike,

If a Zip API is added to the .NET BCL that I can rely on being present and/or freely redistribute then I don't see why not. But until then...

Josh

Posted by bob @ 03 Sep 2008 8:54 AM
HI - this component is great, but if I try to run it as part of a sql agent job, it fails. Any ideas?

Thanks

Bob

Posted by Josh @ 04 Sep 2008 4:17 AM
Do you have any details about the exception? Does the account under which the server agent runs have the appropriate permissions etc?

Posted by Lisandro Fernigrini @ 11 Sep 2008 12:55 PM
I would like to know if it is OK to use this dll in a commercial application. I could not find the license agreement of the source code in any part of this blog. We are deploying a .Net solution that includes a SSIS package and this utility would fit our needs in the final part of the package.
Thanks in advance, and congratulations for your great work.

Posted by Bob @ 08 Oct 2008 12:31 PM
Hi
I am having a great time with this on my local machoine; but if I try to run it on the server in a SQL Agent job, I get the following error:

Error: 2008-10-08 12:13:00.82 Code: 0x00000000 Source: Compress factacreage staging file and archive CompressFileTask-Validate Description: You must specify a source file End Error

But I have specified a source file.

Any idaes?

Thanks for writing this app.

Posted by Bob @ 08 Oct 2008 12:55 PM
HI again - I am getting the error "You must specify a source file" on the package containing the compress file task after I ahe deployed it to the server - one of the dba's cracked open the package, and found that the source file was blank and the destination file contained %SOURCEPATH%\%SOURCEFILE%.gz, which is of course the default - any idea why the the settings I made did not keep after deployment (this was by creating a deployment manifest and using the install wizard to deploy the SSIS package to the server) to the server?

Thanks for your help.

Bob

Posted by James @ 30 Oct 2008 9:53 AM
This task is great. I am getting an error when I deploy the SSIS to the server and try to run it as a job. it says " Source: Compress File Task (v1 1) CompressFileTask-Validate Description: You must specify a source file End Error Error: 2008-10-30 10:37:44.41 Code: 0xC0024107 Source: Compress File Task (v1 1) Description: There were errors during task validation. End Error DTExec: The package execution returned DTSER_FAILURE ". Like stated already, not sure how to fix it. made variables for source and destination steps. and set them in the job it's self, still not working. if I run it in BIDS on the server and on my box and everything works perfect but doesn't run under the agent. any help would be great.

thanks
James

Posted by subash @ 06 Jan 2009 3:32 PM
thank you for your zip task, but where does it get installed and how do i get it on my visual studio tool bar?

Posted by mujtahid @ 14 Jan 2009 10:47 PM
it's working in SQL Server 2005 but, didn't working in SQL Server 2008

Posted by mujtahid @ 14 Jan 2009 10:47 PM
it's working in SQL Server 2005 but, didn't working in SQL Server 2008

thanks,

Posted by Todd McDermid @ 19 Jan 2009 1:59 PM
I've included your task in a directory of custom tasks and components for SSIS on CodePlex. Hopefully more people can benefit from the effort you've put in. Thanks for contributing!

Please visit the SSIS Community Tasks and Components project at http://www.codeplex.com/ssisctc.

Posted by D @ 19 Feb 2009 4:06 PM
This task is exactly what I need! I am just having a little trouble when I change the source and target to variables. This is the error I am getting:
Error: 0x0 at Compress File Task (v1 1), CustomLoggingTask-Execute: Task Errored: System.ArgumentException: The path is not of a legal form.
at System.IO.Path.NormalizePathFast(String path, Boolean fullCheck)
at System.IO.Path.GetFullPathInternal(String path)
at System.IO.FileInfo..ctor(String fileName)
at Tjoc.SqlServer.Dts.Tasks.CompressFileTask.Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, Object transaction)
Task failed: Compress File Task (v1 1)

I have tried running the task by cutting and pasting the evaluated expression into the task (not as a variable) and it works fine. Its just when I put in the variable name that I have problems. Any ideas?

Posted by toni @ 02 Mar 2009 10:43 AM
hello, i have the same requests as subash - could you give more detail on how to incorporate your code into a SSIS package. I have the rest of my package working well but just to include the decompression portion in the beginning. any help is greatly appreciated. thank you

Posted by PT @ 07 May 2009 5:42 AM
Great task but I have the same issue as D: what is the syntax for variables? I've tried strVariableName and @[User::strVariableName] (which works fine when defined in Expressions) but neither work.

Posted by sa @ 18 May 2009 12:00 PM
It doesn't work.

Posted by jimmy @ 01 Jun 2009 8:47 PM
same issue variable doesn't work

Posted by Wenda @ 23 Oct 2009 10:54 AM
Thanks for the code..
To other post I have seen.. If click on the msi and install it. then in opp. click on the bar for "Control flow Items" on the toolbox and select 'Choose items' patiently wait for the box to come up. then select tab 'SSIS Control flow Items' you will see it as an unchecked box. Check it and it will appear in your toolbox.
Another one about syntax for variable Expressions, you can see an example of one set up in the top example.. the Source file is set with a variable.
Now for me and my problem.. What kills me is I am almost sure my first few runs did not have this issue. But I have two variables (which I have outputted the final setup to make sure is set up right.)
The source code has a path, filename and .txt extension. the target same path, filename and .gz extension. It runs no problem.. Finds the file compresses it.. But the file in the compressed .gz file is missing it's extension of .txt.. So when I try to open in it prompts me for the full name.. If I don't put the extension, I get no file..

Posted by Wenda @ 23 Oct 2009 12:36 PM
Found the problem. I lost the .txt when I changed from %SOURCEPATH%\%SOURCEFILE%.gz to a variable name.. It was just filename.gz... When I returned to %SOURCEPATH... I found the internal file had the .txt on it again.. But the compression file is really filename.txt.gz if you remove the .txt from the compression file you also do that to the internal file..

Also I wanted to retract the comment about the Syntax for the variable Expressions. What I used which worked was just the variable name (case sensitive) with no "user::" prefix.

Posted by Aspet @ 21 Dec 2009 10:25 AM
Afer installation,When I tried to add this task to my toolbar,I recieved this error message(The type library C:\program Files\MicroSoft SQL Sever\90... could not be loaded).I tried to add this in ".NET Framework Components" and "COM Components"

Posted by JB @ 29 Jul 2010 6:08 PM
Is there an updated version of this task component that works in SSIS 2008? If so, can you point me to the bits for it? Thanks.

Posted by JB @ 29 Jul 2010 6:08 PM
Is there an updated version of this task component that works in SSIS 2008? If so, can you point me to the bits for it? Thanks.

Posted by JB @ 29 Jul 2010 6:08 PM
Is there an updated version of this task component that works in SSIS 2008? If so, can you point me to the bits for it? Thanks.

Posted by JB @ 29 Jul 2010 6:08 PM
Is there an updated version of this task component that works in SSIS 2008? If so, can you point me to the bits for it? Thanks.

Posted by Josh @ 06 Aug 2010 2:58 AM
Sorry Jim, not that I'm aware of no. I believe the change is easy enough to make and the source is available. It's a long time since I played with SSIS components so don't have time to modify these. Apologies.

Posted by Aaron @ 08 Aug 2010 10:57 PM
If anyone ports to 2008 please post here in the comment list! I need it also

Posted by Paula Luther @ 23 Nov 2010 8:32 PM
Can't download the source or MSI?

© 2005 - 2014 Josh Twist - All Rights Reserved.