none
How to Zip the files in a folder using SSIS package RRS feed

  • Question

  • I need to create a package to zip all the files in the folder and have to FTP the Zip file to vendor. Please help me how can I do this in SSIS?
    Tuesday, January 17, 2012 7:12 PM

All replies

  • If you do not want to pay for third party tools then download a freeware compression utility e.g. GZIP. GZIP is WinZip and Windows built in compression fully compatible, I use it if other compression utilities are not available.

    Then craft up a bat file in which you would set to zip (compress) the files in question (you will need to learn the command line switches).

    In the package drag and drop the Execute Process Task and set to run the bat file, and finally add the FTP task in which you configure to FTP the archive you generate.


    Arthur My Blog
    Tuesday, January 17, 2012 8:57 PM
    Moderator
  • there is actually native compression in SSIS (via .NET)

    I have posted this previously

    Imports

    System.IO

    Imports

    System.IO.Compression

    sub Main()

    compress("Full_File_Path_And_Name_And_Extension")

    end sub

    Public

     

    Sub Compress(ByVal FilePath As String

    )

     

    Dim UncompressedData As Byte

    () = System.IO.File.ReadAllBytes(FilePath)

     

    Dim CompressedData As New

    MemoryStream()

     

    Dim GZipper As New GZipStream(CompressedData, CompressionMode.Compress, True

    )

    GZipper.Write(UncompressedData, 0, UncompressedData.Length)

    GZipper.Dispose()

    System.IO.File.WriteAllBytes(Left(FilePath, InStr(FilePath,

    ".") - 1) + ".gz"

    , CompressedData.ToArray)

    CompressedData.Dispose()

     

    End

    Sub

    This uses native compression in .NET which means that you do not need to install anything on the server - the only downside is that clients need to have 7-zip (or similar) installed to be able to unzip the files
    Rgds Geoff
    Tuesday, January 17, 2012 10:54 PM
  • For the FTP part for the solution

    follow this link

    http://www.sqlservergeeks.com/blogs/raunak.jhawar/sql-server-bi/398/sql-server-2012-ssis-sending-files-using-ftp-task


    Please vote as helpful or mark as answer, if it helps
    Cheers, Raunak | t: @raunakjhawar
    Wednesday, January 18, 2012 4:33 AM
  • You can also get these tasks premade into drag and drop tools: SSIS Community Tasks and Components.
    Todd McDermid's Blog Talk to me now on
    Thursday, January 19, 2012 5:40 PM
    Moderator
  • Hi,

    You can use any of the below to Zip file

    • Script Task Component
    • Execute Process Task
    • Custom Task Component

    Using Script task, you need to write VB/Net code to compress file(in built libraries) as given above by Geoff.  Using Execute process task, you can compress by executing commands( WinZip or Windows compression utility).

    Aslo there are Custom task available on net, download the .dll and register the same in GAC, you can use the same in your BIDS.

    Thanks,

    Adil

     

    Friday, January 20, 2012 6:14 AM
  • One more Script Task example: http://microsoft-ssis.blogspot.com/2011/01/zip-sourcefile-to-archive.html

    It uses the Visual J# Redistributable Packages to zip.

    Or use a third party zip task:



    Please mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com

    Friday, January 20, 2012 7:52 AM
    Moderator
  • you can zip files using Execute Process Task.

    I have attached a figure, in which am zipping all the files in folder(D:\Folder). let me know if you have any queries further.

     


    • Edited by sunilray Friday, January 20, 2012 12:30 PM
    • Proposed as answer by Eswararao C Tuesday, January 24, 2012 11:19 AM
    Friday, January 20, 2012 12:26 PM
  • I found a nice visual tool here:

    http://www.cozyroc.com/ssis/zip-task

     


    MVP MCT MCTS Daniel Calbimonte

    http://elpaladintecnologico.blogspot.com
    Friday, January 20, 2012 4:35 PM
  • Hi Guest389,

    Please refer to the following article details about how to ZIp files using SSIS:

    http://www.sqlservercentral.com/articles/Integration+Services+(SSIS)/64028/

    Thanks,
    Eileen

    Tuesday, January 24, 2012 6:07 AM
  • hi

    is there any way to zip the perticuler file from the given folder.

     

    Regards

    Mahesh

    Wednesday, January 25, 2012 7:35 AM
  • Hi All,

    I reviewed above examples for zipping in SSIS using differetn ways.

    So it looks like we have to use 3rd party lib/tools to implement the zipping functionality.

    Will it be possible by any means of doing this by not using WINZIP/RAR/7ZIP/VSJLIB...?

    i am just trying not to use any 3rd party software on our production box just for this zpping functionality!.

    Any help will be appreciated...

    Thanks a lot.

    vsr

     

    Wednesday, February 1, 2012 5:17 PM
  • To Mahesh,

    if you are using Executable process task, then u can provide u r file details in one of the paramter under Arguments property.

    -min -a "C:\xyz\Desktop\project\zipfilename.zip" "C:\xyz\myfilename.csv"

    hope it helps.

     

    Wednesday, February 1, 2012 5:21 PM
  • You can code a Script Task using .Net compression library as described here: http://msdn.microsoft.com/en-us/library/ms404280%28v=vs.85%29.aspx
    Arthur My Blog
    Wednesday, February 1, 2012 5:23 PM
    Moderator
  • As I mentioned in my example, the code I provided is native to .NET and SSIS - no 3rd party libraries needed on the box

    The only thing that is needed is that the client needs to download 7-ZIP which is shareware (free) - doesn;t need to be loaded onto your prod box, just on any client that may need to unzip the files (the files can also be unzipped using .net code)


    Rgds Geoff ----------------------------------------------------------- Mark as Answer if this resolves your problem or "Vote as Helpful" if you find it helpful.
    Wednesday, February 1, 2012 10:21 PM
  • check this tutorial

    http://www.sqlservercentral.com/articles/SSIS/64028/

    Thursday, February 2, 2012 9:11 AM
  • I'm trying to zip the file using 7z in SSIS package with execute process task. I'm getting error with the following argument. Please advise.

    a  "C:\Program Files\SSIS\Load\Out\TEST.7z" "R:\Program Files\SSIS\Load\Out\TEST" -df

    Tuesday, August 21, 2012 6:39 PM