Hi,
I am having a problem trying to pass a variable to a stored procedure.
create procedure test
@word varchar(10),
@sectionID varchar(max)
as
begin
SELECT * FROM [testtable] WHERE sectionID IN (@sectionID)
end
sectionID sometimes is just one value, like for example 1 and sometimes several different values: 1,2,3,4,5
If I pass one value it works fine, when I pass more than one value I get an error: Conversion failed when converting the varchar to int.
I have tried to use CONVERT(int,@sectionID) and CAST (@sectionID As int) but I got the same error. Is there another way of doing this?
I am having a problem trying to pass a variable to a stored procedure.
create procedure test
@word varchar(10),
@sectionID varchar(max)
as
begin
SELECT * FROM [testtable] WHERE sectionID IN (@sectionID)
end
sectionID sometimes is just one value, like for example 1 and sometimes several different values: 1,2,3,4,5
If I pass one value it works fine, when I pass more than one value I get an error: Conversion failed when converting the varchar to int.
I have tried to use CONVERT(int,@sectionID) and CAST (@sectionID As int) but I got the same error. Is there another way of doing this?