I'm running into an issue when using the index function to return the position of a string within a string.
So I have a concentrated list of surnames:
SMITH|JONES|DONALD
And I want to find the position of a string referenced from another column (SurnametoFind), so:
index(Surnames,'SMITH')
Works perfectly, however, when I reference the column I want to use the value to search on from (a list of single surnames which contains SMITH in one of the rows):
index(Surnames,SurnametoFind)
Returns 0.
This is within an SQL proc, so I also attempted with wildcards (in case index functions like PATINDEX on SQL Server):
index(Surnames,'%'||SurnametoFind||'%')
But this also returns zero.
Am I missing something about how the SurnametoFind column should be referenced in the index function?
Many thanks.