I am using the following code to zip a csv file and pdf. My issue is that I get an error that says:
Msg 102, Level 15, State 1, Line 36
Incorrect syntax near '+'.
the above error refers to the first '+ @Imagename +'
declare @Imagename NVARCHAR(4000)
set @Imagename = '343434'
EXEC master.dbo.xp_cmdshell '"C:\Program Files\WinRAR\Rar.exe" a -ep1 "D:\PO_PICKUP\'+ @Imagename +'.ZIP" "D:\PO_PICKUP\'+ @Imagename +'.csv" "D:\PO_PICKUP\'+ @Imagename +'.pdf"'
Think my issue is with the quotes and double quotes but I just cant figure it out. When I give the code a static value as follows it works. :
EXEC master.dbo.xp_cmdshell '"C:\Program Files\WinRAR\Rar.exe" a -ep1 "D:\PO_PICKUP\34.ZIP" "D:\PO_PICKUP\34.csv" "D:\PO_PICKUP\34.pdf"'
What am I missing in the code with a variable?