I have a table of items and need to select the rows where the item ID is found inside a string formed and retrieved from elsewhere. For example the string to match looks like:
'100684','103223','103228'
or I can strip it to produce:
100684,103223,103228
But I am not getting any success from the following attempts:
SQL = "SELECT * FROM Table Where ID LIKE '" & strString & "' "
SQL = "SELECT * FROM Table Where ID IN '" & strString & "' "
SQL = "SELECT * FROM Table Where PATINDEX('%" & ID & "%','" & strString & "') > 0 "
SQL = "SELECT * FROM Table Where PATINDEX(ID,'" & strString & "') > 0 "
SQL = "SELECT * FROM Table Where CHARINDEX(ID, '" & strString & "') > 0 "
These either fail to produce a result or give an error like
Argument data type int is invalid for argument 1 of charindex function
Use stripped version of your string and try