Question: I have a string value in the web.config — for example 2 guids separated by a `","`. I need to query the database dynamically (i.e i have no idea how many values could be separated by a comma in the web.config) and run a select statement on the table passing these values and getting all that is relevant for example:

```
select * from tablename where columnname = string1 string2 string3 etc etc

```

some strings may only contain 1 guid some may contain 10

Answer: 
Check out Erland Sommarskogs excellent post on this topic:

<http://www.sommarskog.se/arrays-in-sql-2005.html>

SQL Server 2008 would also offer [table-valued parameters](http://www.sqlteam.com/article/sql-server-2008-table-valued-parameters) in addition to these ways of passing multiple values to the procedure.

Marc
You don't have to send multiple parameters, only one string

A posibility is to parse that string into an SQL stored procedure and build a dynamic query

Another posibility is to insert the '' characters at every , and use to code below

```
'aaa','bbb','ccc'

myTable
------------
ID  Name

1   eee
2   aaa
3   ggg
4   hhh
5   bbb

declare @stmt nvarchar(1000)
set @stmt = 'select * from myTable where Name in (''aaa'',''bbb'',''ccc'')'
exec spexecute_sql @stmt

```