I have a SP which looks up a product (only one) by its productid just like this (it's a very simplified version of the query)
ALTER PROCEDURE [dbo].[MYSP]
@productid int
AS BEGIN
SET NOCOUNT ON
select * from products where productid = @productid
END
EXEC MYSP 10
In some special cases I need to provide two or more productid but I am NOT allowed to pass more than ONE parameter to the SP so I tried to change the parameter from INT to VARCHAR and do:
ALTER PROCEDURE [dbo].[MYSP]
@productid varchar(10)
AS BEGIN
SET NOCOUNT ON
select * from products where productid IN (@productid)
END
EXEC MYSP '10,20,30'
However it will return me a conversion error because the productid column in the table is INT.
There is a workaround for this?
Thanks!