SQL Server Performance

unzip files in DTS

Discussion in 'General DBA Questions' started by seanpk, Apr 18, 2005.

  1. seanpk New Member

    I have some files that are zipped via WinZip. I would like to setup a DTS process that will uncompress (unzip) the files so I can extract the contents into SQL Server tables.

    Can this be done - and if so, how?

    Thanks,

    sk
  2. dineshasanka Moderator

    You can do this by using Execute Prosses task. Sorry I don't know the parameters. I will try post the parameters within today.

    If you find those parametrs please post them here
  3. dineshasanka Moderator

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

    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 ...


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

    SET @ZipFileName = 'MyZipFile.Zip'

    SET @SQLCommand =
    'exec master..xp_cmdshell ' + '''' + 'C:MyDirWinzipWZUNZIP -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!


    quote:Originally posted by dineshasanka

    You can do this by using Execute Prosses task. Sorry I don't know the parameters. I will try post the parameters within today.

    If you find those parametrs please post them here

Share This Page