c# - passing my comma separated string won't generate results in SQL -


this question has answer here:

i have need pass comma delimited string parameter stored procedure. string contains ints seperated commas. need use ints in 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 have parameter passing stored proc containing string parameter ="50001362,50001414,50001437,50001630,50001643,50001659,50001775,50001272,50001276,50001220,500012226"

i have tried using dynamic sql , doing referencevalue in ( '+@groupnumbers+' ) however, no results

at top of stored proc declaring variable

declare @groupnumbers varchar(1000) set @groupnumbers = '50008300,50002427' 

the set test case see how can results comma delimited string. need pass in string of group numbers parameter , results. looping through each group number , calling query each group number.

any advice on doing wrong? novice @ sql.

thank you

please refer answer in other post how convert delimited string list

then after have decided either use clr method or sql udf method can following:

select *   dbo.yourtablehere t  inner join dbo.fnarray(@groupnumbers, ',') g on t.somefield = convert(int, g.arrvalue) 

should want.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -