sqlor
August 25, 2022, 2:13am
1
Hello
Is it possible to use soundex or other algo to match e.g.:
ABC Inc
with
xxxx xxxxx ABC Corp xxxx xxxx
(where x is any character)
In other words, fuzzy match usually compares the whole strings as one but I would like to also match if the reference string has a fuzzy match somewhere inside the to be checked string.
Thanks!
SQL Server has a SOUNDEX() function you can use.
sqlor
August 25, 2022, 3:09pm
3
Yes but it does not work in the way I want to, i.e. check if a string exists as a substring in another list?
one thing is LIKE operator
RegEx may help you
Being able to do complex queries can be really useful in SQL. In this article, we'll look at how you can use the Contains String query. SQL Patterns SQL patterns are useful for pattern matching, instead of using literal comparisons. They have a more...
sqlor
August 26, 2022, 2:42pm
5
Thanks but was looking for SOUNDEX of a reference string vs another field that may have the SOUNDEX as substring
declare @fuzzy_bear table(gumbo nvarchar(max))
insert into @fuzzy_bear
select 'xxxx xxxxx ABC Corp xxxx xxxx'
declare @inc nvarchar(10) = 'ABC Inc'
select *, DIFFERENCE(c.item, @inc) , SOUNDEX(c.item), soundex(@inc)
from @fuzzy_bear a
cross apply alba.dbo.DelimitedSplit8K(a.gumbo,' ')c
select *, DIFFERENCE(c.item, @inc) , SOUNDEX(c.item), soundex(@inc)
from @fuzzy_bear a
cross apply alba.dbo.DelimitedSplit8K(a.gumbo,' ')c
where SOUNDEX(c.item) = soundex(@inc)
DelimitedSplit8K by @JeffModen
The Tally Table has proven to be a simple and elegant method for avoiding many varieties of RBAR. Unfortunately, one of its more common uses, that of a CSV splitter, has a well-known and serious performance problem. MVP Jeff Moden shows us what that...
1 Like