Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Compare a row with every other row?

Author  Topic 

loneblade
Starting Member

3 Posts

Posted - 2010-04-14 : 17:21:02
I need to do a fuzzy match with a table that has duplicate company names due to misspelling or different naming conventions, and group the duplicates together by creating an group id for each set of matches. I have found the Jaro-Winkler at http://www.sqlservercentral.com/articles/Fuzzy+Match/65702/, but I am having a hard time figuring out the next step.

Is there anyway to grab a row, match it with every other rows in the table, and repeat the process for every row?

malpashaa
Constraint Violating Yak Guru

264 Posts

Posted - 2010-04-14 : 17:59:16
Yes you can and one way to do this is to use APPLY
So try something like this:

SELECT T1.name, T2.name, T2.match
FROM SomeTable AS T1
CROSS APPLY
(SELECT T2.name, SomeFunction(T1.name, T2.name) AS match
FROM SomeTable AS T2) AS T2
Go to Top of Page

loneblade
Starting Member

3 Posts

Posted - 2010-04-14 : 20:50:52
Thanks, this worked great. =]
Go to Top of Page
   

- Advertisement -