I've got an Office Data Connection running a SQL query against an external data source and using some dynamic parameters provided in cell in a worksheet. As long as I'm doing something like
SELECT * FROM TABLE1 WHERE FIELD1 = ?
and setting the parameter source appropriately things work fine. However if I try something like
SELECT * FROM TABLE1 WHERE FIELD1 IN (?)
Any attempt to provide a value like 1,3,5,7
the query seems to only pay attention to the first value in the list, not the whole source (so using 1,3,5
I get rows with a 1 in the corresponding field, and with 3,5,7
I get rows with a 3 in the corresponding field).
Is there a way for me to provide a list of values to use as the parameter value in an IN operator in the SQL query that I'm totally missing?
EDIT
I'm putting the list of parameter values in a single Excel field. Excel also automagically prepends the field value with '
, as it does to escape values that it needs to treat as text. No combination of cell formatting seems to get rid of the '
character.
Providing (1,3,5)
in the query body instead of (?)
works as expected; it's only when trying to use an excel cell as a dynamic parameter that things don't work.
SELECT * FROM TABLE1 WHERE FIELD1 IN (1,3,57)
works as expected? Do you have1,3,5,7
in the same one cell, or each number in its own cell?