How to write stored procedure to do this?

Posted by chobo on Stack Overflow See other posts from Stack Overflow or by chobo
Published on 2010-02-11T21:27:15Z Indexed on 2010/03/12 8:57 UTC
Read the original article Hit count: 143

Filed under:
|
|
|

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!

© Stack Overflow or respective owner

Related posts about sql

Related posts about tsql