Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: SQL Server
Expertise: Beginner
Jul 15, 1999

Reporting duplicates

Question:
I am having trouble figuring out how to make a report dealing with duplicates. I need to selcet from a table only instances where the first 10 characters of two columns match. For example, I combine the first and last name columns with (||), then I need to take the first 10 letters of the combined column and compare them to the rest of the table to match potential duplicates.

Answer:
Try this and see if it gets you there, or at least gets you started. Play with the length of the second argument in the substring function to see how it changes the columns returned.


create table #dummy (mushedupname Varchar(100))
insert #dummy select au_lname+au_fname from authors as mushedupname

select a.mushedupname, b.mushedupname
 from #dummy a,  #dummy b
where substring(a.mushedupname,1,5) = substring(b.mushedupname,1,5)

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date