Reputation: 77
I can unzip files using only SQL by the following command:
exec master..xp_cmdshell 'C:\Progra~1\7-Zip\7z.exe e "Path\t.zip" -o"OutputPath"'
But I would like this procedure to be installed into different servers and I cannot guarantee that all of them will have 7z installed.
Could I:
Upvotes: 1
Views: 7896
Reputation: 11739
Others suggest you can use Powershell which would have been the only older native windows method for XP to early Windows 10.
But current Windows 10 and 11 have a command line unzipper in Tar.EXE. it is easy once you understand its oddities to unpack/update from local or web zip files etc. (for web.zip using curl)
Example general usage https://stackoverflow.com/a/70011759/10802527
OR say for download chrome headless shell try something like
set "download=chrome-headless-shell-win32.zip"
set "variant=win32/%download%"
curl -o LATEST_RELEASE_STABLE.txt https://googlechromelabs.github.io/chrome-for-testing/LATEST_RELEASE_STABLE
set /p version=<LATEST_RELEASE_STABLE.txt
curl -O https://storage.googleapis.com/chrome-for-testing-public/%version%/%variant%
tar -xf %download%
Usage is only limited by your ingenuity.
Upvotes: 0
Reputation: 1
Instead of 7z try to use the Windows/PowerShell function:
exec master..xp_cmdshell 'powershell -command "Expand-Archive -Force C:\test\TEST.zip C:\test\TEST\'
Upvotes: 0