Link to home
Start Free TrialLog in
Avatar of Curtis Long
Curtis LongFlag for United States of America

asked on

SQL Server 2008 search for and remove dulpicates

I have a table called plant.  A column called certificate.

Is there a way to check the column certificate for duplicates and remove all but one original??

Avatar of lludden
lludden
Flag of United States of America image

How do you determine the original?  Is there an identity field?

if so, you can use

DELETE FROM plant
WHERE PlantID NOT IN (
SELECT MIN(PlantID), Certificate
GROUP BY Certificate)
Avatar of Curtis Long

ASKER

If I have 10 certificates as follows:

10003
10004
10005
10006
10007
10008
10009
10010
10011

Now the certificates 10003 and 10007 are duplicated.

There should NEVER be two of the same numbers in this column.

Is there a way to delete the dulpicate or set it to flag it some how??  IE highlight etc??
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial