how can i Zip a file

  • I’m having a problem of how I can do this in SSIS( file must be zipped, the zipped file must have the same name, but have extension .C001. The zipped file must be given a password and saved to a folder on a server. The folder where it is saved to must be a variable, the person who runs the DTS package must supply the location to where the zipped file must save. E.g. ‘\\sfh-th1\DTS’)

  • If you're using WinZip, you'll need the "pro" version, which comes with command-line abilitites, and a trip to the "shell", what ever it's called in SSIS.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • To expand on Jeff Moden's post. You will need to use the Execute Process Task. You will need a Zip utility with a command-line capability.

    😎

  • In our shop use 7-zip (http://www.7-zip.org/), which is a freeware zip utility with command line support. It will likely do what you need if you don't already have a package that will do it.

  • Hi,

    You need to work around with something like this....Find all command options available through winzip..It has password (-s) command etc...You need to use xp_cmdshell, unless you are not fan of it and build dynamic sql .

    select @execstr = 'master.dbo.xp_cmdshell ''c:\winzip\Wzzip.exe -m -ybc -s(password) -y '

    + rtrim( @BackupPath ) -- zip destination full path

    + rtrim( @Name ) -- zip destination filename part

    + '.zip ' -- zip file extension

    + rtrim( @BackupPath ) -- backup file source full path

    + rtrim( @Name ) -- backup filename part

    + rtrim( @FileType ) -- backup file extension

    + '''' -- close single quote for xp_cmdshell

    -V

  • You may also use the Script task and a .Net library to accomplish this...


    Cheers,

    Ben Sullins
    bensullins.com
    Beer is my primary key...

  • veenagireesha (5/21/2008)


    Hi,

    You need to work around with something like this....Find all command options available through winzip..It has password (-s) command etc...You need to use xp_cmdshell, unless you are not fan of it and build dynamic sql .

    select @execstr = 'master.dbo.xp_cmdshell ''c:\winzip\Wzzip.exe -m -ybc -s(password) -y '

    + rtrim( @BackupPath ) -- zip destination full path

    + rtrim( @Name ) -- zip destination filename part

    + '.zip ' -- zip file extension

    + rtrim( @BackupPath ) -- backup file source full path

    + rtrim( @Name ) -- backup filename part

    + rtrim( @FileType ) -- backup file extension

    + '''' -- close single quote for xp_cmdshell

    -V

    You don't need to use xp_cmdshell. As I stated earlier, you can also use the Execute Process Task. That is how we use gzip to compress files before FTPing them to an outside source.

    😎

  • xp_cmdshell is disabled by default in SQL 2005 so unless you have had your administrators enable it (not recommended) you won't be able to use it. Like Lynn said, us the Execute Process task or build a Custom Assembly to handle it...


    Cheers,

    Ben Sullins
    bensullins.com
    Beer is my primary key...

  • Hi All

    thanx for your help.

    If i use Execute Process Task how is the user of the package going to be able to supply the location to where the zipped file must be saved. coz when u use Execute Process Task it save on the some folder when the file your zipping is.

    And how can i change the extension of the zip file coz it needs to change from C001 to C002 ever time when i run the package?

    regards

    Nosi

  • If necessary, you could follow the Execute Process task with a File System task to move and/or rename the file. The source and destination paths can be mapped to user-defined variables which can for example be supplied as part of a command line or modified in a configuration file.

  • I Just recently posted a blog post on this: http://blog.cybner.com.au/2008/05/unzip-files-using-ssis.html

    Hope this may help 🙂


    Kindest Regards,

    Catherine Eibner
    cybner.com.au

Viewing 11 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply