Recently, while working on SSIS we came across a situation to use parameters. We wanted to pass 2 parameters.
We were using SQL Command as Data access mode in OLE DB Source Editor.
After writing the query the below query:
select ? from channelmaster where displaychannel=?
When we clicked on parameters to provide the parameter values we got the error as shown below:
The parameter type for ‘@P1’ cannot be uniquely deduced; two possibilities are ‘sql_variant’ and ‘xml’
To fix this issue, we did the type cast of above parameters first before clicking on Parameters button. In our case, we did type cast them to varchar(30) as shown below:
select cast(? as varchar(30)) from channelmaster where displaychannel=cast(? as varchar(30))
After doing this, when we clicked on Parameters button, it asked for value of the parameters as shown below:
Basically, when there is a scenario to select the value that comes through the parameter then we need to type cast that parameter.
Hope it helps !!
This really helped Ajit. Simple info, but very useful.
LikeLike