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)
 Check for duplicates...

Author  Topic 

qman
Constraint Violating Yak Guru

442 Posts

Posted - 2009-11-23 : 12:04:18
Some contact records in our Contact Table have duplicate data stored in their match_code field. I would like to identify these records so that I can update the match_code to make them unique.

I know there are other ways to show uniqueness, but I need to use this match_code column.

Any ideas...?


select * from Contact
where match_code = ??

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-11-23 : 12:06:57
do you mean this?

SELECT *
FROM
(
SELECT ROW_NUMBER() OVER (PARTITION BY match_code ORDER BY <any other unique valued column>) AS Seq,*
FROM table
)t
WHERE Seq >1
Go to Top of Page

qman
Constraint Violating Yak Guru

442 Posts

Posted - 2009-11-23 : 12:44:18
Yes, very cool!

Thank you....
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-11-23 : 12:45:15
welcome
Go to Top of Page
   

- Advertisement -