I have a table that has some columns containing strings ,Let's say nvarchar
. Now, the user passes a string to a function that searches for this string in its assigned column. I want to check if that string is present in the database but the problem is it does not necessarily have to be a 100% match.
Let's say for example:
The user passed the string Johnathon
and string John
is present in this database.
So, basically I want to get the number of characters that matched.In this particular case of John
and Johnathon
. it should be 4 matched and 5 unmatched.
Can I please get some directions to approach this problem?
Edit: What I am guessing is I can do the percentage match thing once I have retrieved the best matching string from the column. So, likewise, if we ignore the number of matched and unmatched characters and focus on retrieving the matched string from database, that should work.
Forexample, as Johnathon
was passed by the user, and John
is present in the database, I definitely can not use Like
operator here but a piece of code that searches for the most matched string in the column and returns it.