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 2005 Forums
 Transact-SQL (2005)
 Finding duplicates based on business rules

Author  Topic 

JasonJanofsky
Starting Member

5 Posts

Posted - 2007-02-23 : 12:15:22
Hey there,

I am looking for a hint as to what to search for or what to read regarding finding possible duplicate data in my DB.

Consider the following table:

ID Name
---- -------------
1 Joes Pest Service
2 Alabama Rock Supply
3 Joe's Pest Services

Obviously, records 1 and 3 are unique data to SQL, but in our business rules I would like to do some kind of magic that will return records 1 and 3 so that a user might decide how to correct the duplicate error.

It seems like I need some kind of google search within my DB to come back with a percentage match? Oh well, any help I can get I appreciate.

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-02-23 : 12:43:16
[code]declare @t table
(
[ID] int,
[Name] varchar(100)
)

insert @t
select 1, 'Joes Pest Service' union all
select 2, 'Alabama Rock Supply' union all
select 3, 'Joe''s Pest Services'

select t1.[ID], t1.[name]
from @t t1 cross join @t t2
where t1.[id] <> t2.[id]
and difference(t1.[name], t2.[name]) > 0
[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -