This article provides a few techniques to work with 'in-clause' in queries, ado.net, stored procedures, and SQL Server.BackgroundDuring the years of developing, it can be interesting to try different ways to solve the same solution. In this case, its searching for the best way to deal with a tricky SQL Server and other RDBMS issue of querying with an “in-clause” where there's an unknown number of values for the clause. A typical scenario is a situation that builds up a set of row ids to query for. The scenario could be a screen where the user picks a few values in a ListBox or bunch of check boxes in a grid. Another scenario could be a batch process that identifies a bunch of ids to work on. Ids are usually a unique value and sometimes show up more than once in the set. So, how many different ways can we set up something likeselect * from sometable where id in ( X number of ids )The part that makes this tricky is each value in an in-clause has to be independent. Select * from sometable where id in (1, 400, 33, 333)So using one variable to represent '1,400,33,333' just won't work.Declare @ids = '1,400,33,333'select * from sometable where id in (@ids) -- boom ApproachesOkay, so how about a few approaches to work around this issue: dynamic sql, parameterized sql, stored procedure using delimited string and temp table, stored procedure using delimited string to parameter table, stored procedure using delimited string and variable table, stored procedure using XML, and stored procedure using value type. That should be enough to build on. I'm focusing on SQL Server 2008 here. There are other techniques for SQL Server and other RDBMS. Read more: Codeproject