INTELLIGENT WORK FORUMS FOR COMPUTER PROFESSIONALS
Come Join Us!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- Turn Off Ad Banners
- 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.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site

(Download This Button Today!)
Member Feedback
"...Keep up the good work - excellent site - i'd been looking for something like this for ages !..."
Geography
Where in the world do Tek-Tips members come from?
|
Microsoft SQL Server: Programming FAQ
|
3rd Party Applications
|
Using WinZip in SQL Server
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 ...
CODEdeclare @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 FAQ Archive
Email This FAQ To A Friend |
|
 |
|