I am facing issues when I run SSIS package with parameters but without parameter it works.
What could be the problem?
Query without parameter-
Begin
declare @query varchar(4000) =
'dtexec /Project C:\SSIS\DUTPackages.ispac /Package cityTransfer.dtsx /decrypt password1!'
exec xp_cmdshell @query
End
Query with parameter-
Begin
declare @p_cityId varchar(10) = '%'
declare @p_count varchar(10) = '-1'
declare @query varchar(4000) =
'dtexec /Project C:\SSIS\DUTPackages.ispac /Package cityTransfer.dtsx /decrypt password1!'
+ ' /SET \Package.Variables[$Package::p_cityID];''' + @p_cityId + ''''
+ ' /SET \Package.Variables[$Package::p_count];''' + @p_count + ''
exec xp_cmdshell @query
End
Error I get when running query with parameter-
[OLE DB Source [25]] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E10.
[SSIS.Pipeline] Error: OLE DB Source failed the pre-execute phase and returned error code 0xC0202009.
I think you might just need to add some double quotes and remove a couple single quotes. Try this:
Begin
declare @p_cityId varchar(10) = '%'
declare @p_count varchar(10) = '-1'
declare @query varchar(4000) =
'dtexec /Project C:\SSIS\DUTPackages.ispac /Package cityTransfer.dtsx /decrypt password1!'
+ ' /SET "\Package.Variables[$Package::p_cityID];' + @p_cityId + '"'
+ ' /SET "\Package.Variables[$Package::p_count];' + @p_count + '"'
exec xp_cmdshell @query
End
在某些情况下,仅参数需要用“。”引起来。因此,请尝试- '" + @p_cityId + "'
, @p_count
相同
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.