I've got the following piece of SQL Code that is giving me a titular error.
WHERE
(SELECT Tokens FROM StringSplitter(@DocumentValue, '|', 1)) IN
(SELECT Tokens FROM StringSplitter(@sortValue, '|', 1))
Where @DocumentValue and @sortValue are both concatenated strings separated by a delimiter (in this case, a '|').
The StringSplitter function returns a table of each individual string. e.g. Fox|Brown|SQL would return a table with three records: Fox, Brown, and SQL.
What I want to happen is to compare the two sets of strings, inserting them into another table (hence the WHERE) if any of the individual strings from @DocumentValue match any of the individual strings from @sortValue.
This implementation is flawed. If @DocumentValue and @sortValue ever contain more than one matching string, the query fails, with the given error.
That said, how could I fix this error considering I don't care which value matched, as long as I know whether or not at least one did?
Sql Server 2008