Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Unzip file using powershell with sql variable as input

$
0
0

I have a query that unzip files using winrar, but I need to use powershell to unzip files with in the same code, here problem is : zip file name is a variable, so need to pass sql variable (@EquiantFile ) in powershell. In actual script we rename file name that comes into folder with current date

Select @EquiantFile = @InPath +'\Status_and_Notes_' + replace(convert(varchar(8),@EffectiveDate,10), '-', '_') + '.Zip'

"I need to use powershell.exe to unzip file instead Winrar.exe"

Existing code:

Declare @EquiantFile varchar(300)

Declare @inpath varchar(300)

Select @EquiantFile = 'D:\temp\finova\Status_and_Notes.zip'

Select @inpath = 'D:\temp\'

Select @EquiantFile = 'C:\"program files"\WinRAR\Winrar.exe X -o '+@EquiantFile+' '+@InP EXEC ('exec master..Xp_Cmdshell '''+@EquiantFile+'''')



Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>