Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using WinZip in SQL Server

3rd Party Applications

Using WinZip in SQL Server

by  JayKusch  Posted    (Edited  )
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!
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top