Unzip file from T-SQL Script

  • Hi All,

    How to unzip file by using T-SQL Script ? any Examples pls...?

  • Can't be done directly from t-sql. You need to invoke the command line using xp_cmdshell. There are plenty of zip tools around which provide a CLI and give you their syntax.

    If you're using a job you could do this using powershell as an alternative to the standard command line.

    A final alternative, you could write your own CLR function for SQL Server.

  • MysteryJimbo (1/3/2014)


    Can't be done directly from t-sql. You need to invoke the command line using xp_cmdshell. There are plenty of zip tools around which provide a CLI and give you their syntax.

    If you're using a job you could do this using powershell as an alternative to the standard command line.

    A final alternative, you could write your own CLR function for SQL Server.

    Thanks for you reply... I googled on this batch file i got some idea.. but i couldn't get fully .. Can u please provide one example by using xp_cmdshell.

  • MysteryJimbo (1/3/2014)


    Can't be done directly from t-sql. You need to invoke the command line using xp_cmdshell. There are plenty of zip tools around which provide a CLI and give you their syntax.

    If you're using a job you could do this using powershell as an alternative to the standard command line.

    A final alternative, you could write your own CLR function for SQL Server.

    Thanks for your reply... I googled on this batch file i got some idea.. but i couldn't get fully .. Can u please provide one example by using xp_cmdshell.

  • Do what I'd do, and type "xp_cmdshell" into your favourite search engine. If you're not familiar with the command line syntax of whatever zip utility you're using, you'll need to look that up as well. Post back if you get stuck on anything in particular.

    John

  • There are lots of examples right here on the site. Just do a search for xp_cmdshell and zip.

    Here's one example here. And another. And one more[/url]. There are still others to be found.

    ----------------------------------------------------The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore RooseveltThe Scary DBAAuthor of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd EditionProduct Evangelist for Red Gate Software

  • Thanks for you help.. i got it...

Viewing 7 posts - 1 through 6 (of 6 total)

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