use of 'IN (...)' on a where clause and parameters

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to format a command with a WHERE clause that use IN (...) condition
and I need to create the list in the IN statement dinamically.
Is there a way to do it using parameters on ADO.NET?
Thanks
 
No, not as far as I know.

You would have to build the IN clause and make sure you prevent any SQL
injection attacks yourself.
 
The SQL syntax does not support this, but it's possible (through several
techniques) to pass in a delimited string as a parameter and use a
table-returning SQL function to return a (in-memory) table containing a row
for each parameter. The IN clause permits you to include a subquery SELECT
against this table. This is documented on the web.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Back
Top