Hi, I have that procedure which returns rows associated by ID with passed argument, i.e 1,5,7,9
ALTER PROCEDURE [dbo].[get_data]
@MyCodes as varchar(max) = ''
AS
BEGIN
DECLARE @query as nvarchar(max)
set @query = 'SELECT name FROM user WHERE id IN (@p_MyCodes)'
exec SP_EXECUTESQL @query,
N'@p_MyCodes varchar(max)',
@p_MyCodes = @MyCodes
END
That procedure generates an error : Error converting data type varchar to numeric. when I pass as an argument e.g. 3,7,5
What's wrong ?