I call the SSIS package remotely using a stored procedure and calling xp_cmdshell:
declare @cmd varchar(5000)
set @cmd = '"C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\dtexec.exe" /Rep E /Sql Package /SET \Package.Variables[User::ImportFileName].Value;c:\foo.xlsx'
print @cmd
exec xp_cmdshell @cmd
This works fine, however, I cannot guarantee that the value of the variable (c: \ foo.xslx) will not contain spaces, so I would like to avoid this with quotes, as shown below:
set @cmd = '"C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\dtexec.exe" /Rep E /Sql Package /SET \Package.Variables[User::ImportFileName].Value;"c:\foo.xlsx"'
But at the same time I get an error
'C:\Program' is not recognized as an internal or external command, operable program or batch file.
Both of these commands work fine if executed in cmd.exe, so I assume that SQL Server interprets my double quotes and changes something, but I can’t figure out what.
source
share