Zipping Files

  • Hi

    I was wondering if anyone has managed to zip files from SQL Server in a stored procedure.

    We are doing a select query to output table then exporting it to text on the server. As we need to email the results out to external people we zip the files up manually at the moment and then send them. I would like to put this into a stored procedure so that it is all handled in 1 job.

  • Take a look at 'xp_cmdshell' in BOL This should be what you need

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • -- Install WinZip. It has to be licensed version.

    -- Download and install command line utility wzzip.exe from WinZip site.

    -- Zip file. Delete original.

    set @sCmd= '"c:\Program Files\WinZip\wzzip.exe" -ex -m \\FileServerName\e$\Temp\FileName.zip \\FileServerName\e$\Temp\FileName.txt'

    EXEC @iRetCode = master..xp_cmdshell @sCmd

    IF @iRetCode <> 0

    print('Error')

    There are quite a few command line switches besides the one presented above.

    Voytek

  • hi,

    what is FileServerName means? what should i have to give in that?

  • I use 7-zip to compress files. Here[/url] I had posted on how to use 7 zip in a script.

    Pradeep Adiga
    Blog: sqldbadiaries.com
    Twitter: @pradeepadiga

Viewing 5 posts - 1 through 4 (of 4 total)

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