Hi there,
As per your SP code, you are passing 4 parameters to the SP, but as per the values you pass to the SP, it would consider as more than 4 parameters that causes this error. That is because, COMMA is used as a delimiter for the parameters list in the SP.
When you say
Code:
Execute MyProc a, b, c, d
would denote that you are passing 4 parameters, where the MyProc would be coded to take only one Paramter. That way you cannot pass commma separated values to be used inside the SP with IN operator.
You can go for a workaround in that case. Anything you would like to pass as parameter to be used with IN operator can be passed with someother delimiters, and will be replaced with comma inside the procedure as given below.
Code:
Create procedure MyProc @param varchar(25)
Declare @sql varchar(55)
set @sql = 'select * from YOURTABLE where ID in (' + replace(@param,'-',',') + ')'
exec(@sql)
Code:
Exec MyProc @param = '1-2-3-4-5-6'
Use anything other than COMMA there.
- or
: or
_ or anything that doesn't have special meaning.
PS: REPLACE function works only with SQL server.
Hope that helps.
Cheers!
_________________________
- Vijay G
Strive for Perfection