I have a query in a myTableAdapter that ends with WHERE column IN (@S). This works fine when I use myTableAdapter.Fill(dataset.table, “text”) but I can’t find any way that works to provide multiple text strings such as “text1, text2” for the IN parameter. How can this be done?
Share
This is not possible as it stands as far as I know.
The alternative is to use dynamic SQL (i.e. generate the
WHEREclause in code), but this is bad practice unless you really don’t care about security, maintainability or readability!The other extreme involves writing a table-valued function to live on the db server that accepts your
@Sparameter.This param should be a delimited string which you could then parse within the function using T-SQL
WHILEandBEGIN ... ENDconstructs, inserting each item from your string into a temp table.Finally, your query’s
WHEREclause would then become something like: