Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

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



Application Security Testing: An Integral Part of DevOps

Reporting duplicates

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.

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.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date