I would like to create a stored procedure that takes in a string of comma separated values like this “1,2,3,4”, and break it apart and use those numbers to run a query on a different table.
so in the same stored procedure it would do something like
select somefield from sometable where somefield = 1
select somefield from sometable where somefield = 2
select somefield from sometable where somefield = 3
select somefield from sometable where somefield = 4
Thanks!
Check out Erland Sommarskog’s excellent article on the topic of how to pass a list of values to a stored procedure in SQL Server 2005:
Arrays and Lists in SQL Server 2005 and Beyond
From that, you should be able to create your query based on the criteria you have.