I Have a need to pass a comma delimited string as a parameter to a stored procedure. That string contains ints seperated by commas. Then I need to use the ints in an IN clause, like, "where ReferenceValue in ( '50022056', '50022073', '50022075', '50022072', '50022086', '50022095', '50022074', '50022077', '50022100', '50022101', '50022106', '50022107', '50022108', '50022109', '50022110', '50022111', '50022112', '50022113', '50022115', '50022116', '50022117', '50022118', '50022119' )"
Now I have a parameter I am passing to a stored proc containing string parameter ="50001362,50001414,50001437,50001630,50001643,50001659,50001775,50001272,50001276,50001220,500012226"
I have tried using Dynamic SQL and doing where ReferenceValue in ( '+@groupNumbers+' ) however, i get back no results
At the top of my stored proc i am declaring the variable
DECLARE @groupNumbers VarChar(1000)
SET @groupNumbers = '50008300,50002427'
The SET is just a test case to see how I can get back results with a comma delimited string. I need to pass in my string of group numbers into this parameter and get back results. Currently i Am looping through each group number and calling the query with each group number.
Any advice on what i am doing wrong? I am very novice at SQL.
Thank you