INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

3rd Party Applications

Using WinZip in SQL Server by JayKusch
Posted: 21 Apr 04

This method can be tailored to use Winzip for zipping or unzipping files within SQL Server (SPs, DTS Packages ...)

Pretty easy to do BUT you will need to buy a licensed copy of WinZip ... and as often as EVERYONE uses it ... its worth buying a copy just once - LOL.

You will also have to download the current version of the WinZip Command Line interface from their site.

The reason for the license is that when you register Winzip, it removes the commercial/company header message from being displayed when you run Winzip in the command line. If you do not register the software, the Unzip will hang. So in say that ... here is the code to unzip a file thru SQL Server ...

CODE

declare @ZipFileName VarChar(50)
declare @SQLCommand  VarChar(400)

SET @ZipFileName = 'MyZipFile.Zip'

SET @SQLCommand =
'exec master..xp_cmdshell ' + '''' + 'C:\MyDir\Winzip\WZUNZIP -yb  C:\MyDir\'
+ @ZipFileName + ' C:\MyDir\' + ''''

EXEC (@SQLCommand)

What the code is doing above is starting WZUNZIP that has been installed in the C:\MyDir folder. It is Unzipping a zipped file called MyZipFile.zip which was passed in as a variable. It will unzip the file to the C:\MyDir folder.

This should get you most of the way! Enjoy!

Back to Microsoft SQL Server: Programming FAQ Index
Back to Microsoft SQL Server: Programming Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close