I am using SQL Server 2008 and need to write a query that should return a record of ABCDEFGH
if a user enters a search string such as ABCD-EFGH
or ABDEFGH
etc (i.e. records that are similar to).
How would I accomplish that?
I am using SQL Server 2008 and need to write a query that should return a record of ABCDEFGH
if a user enters a search string such as ABCD-EFGH
or ABDEFGH
etc (i.e. records that are similar to).
How would I accomplish that?
you need to employ some sort of editDistance algorithm i.e Levenshtein distance ,Jaro–Winkler distance to calculate the difference between 2 strings.
look at this thread for Levenshtein distance implemented as udf
you will use the UDF like this (just an example)
SELECT * FROM dbo.myTable
WHERE dbo.editDistance(mycol,@SearchString)<2