T-SQL How To: Compare and List Duplicate Entries in a Table
Posted
by Dan7el
on Stack Overflow
See other posts from Stack Overflow
or by Dan7el
Published on 2010-06-10T13:03:32Z
Indexed on
2010/06/10
13:22 UTC
Read the original article
Hit count: 439
SQL Server 2000. Single table has a list of users that includes a unique user ID and a non-unique user name.
I want to search the table and list out any users that share the same non-unique user name. For example, my table looks like this:
ID User Name Name
== ========= ====
0 parker Peter Parker
1 parker Mary Jane Parker
2 heroman Joseph (Joey) Carter Jones
3 thehulk Bruce Banner
What I want to do is do a SELECT
and have the result set be:
ID User Name Name
== ========= ====
0 parker Peter Parker
1 parker Mary Jane Parker
from my table.
I'm not a T-SQL guru. I can do the basic joins and such, but I'm thinking there must be an elegant way of doing this. Barring elegance, there must be ANY way of doing this.
I appreciate any methods that you can help me with on this topic. Thanks! ---Dan---
© Stack Overflow or respective owner