Having a table (Table1
) with Columns -> Column1 int, Column2 int, Column3 varchar(128), Column4 char(11)
Need to create a stored procedure to get the details from Table1 based on the input parameter. Input parameter holds values with comma-separated. It has to be mapped with Column1
Create Procedure ProcedureName(@InputParams VARCHAR(MAX))
AS
BEGIN
SELECT Column2
,Column3
,Column4
FROM Table1
WHERE Column1 IN (@InputParams)
ORDER BY Column2
END
The below statement is throwing conversion error
"Conversion failed when converting the varchar value '123, 456, 789' to data type int."
EXEC ProcedureName @InputParams = '123, 456, 789'
Converting the SELECT statement to the dynamic query will work fine but will we able to fix the conversion issue in the static query. Please help me.