SQLname = "SELECT name FROM dbo.table WHERE id IN("+String.Join(",", items.ToArray())+");";
using (var comm = new SqlCommand(SQLname, conn, null))
{
using (var reader = comm.ExecuteReader())
{
while (reader.Read())
{
}
}
}
create procedure p(
@ids xml
)
begin
select name
from
dbo.table
inner join @ids.nodes('/items/item') root(items)
on id = items.value('(text())[1]', 'int')
end
<items>
<item>1</item>
...
<item>1000</item>
</items>