1

Possible Duplicates:
Remove duplicates in large MySql table
Can I extract the extract records that are duplicated in sql?
How can I delete duplicate rows in a table

I need something to delete repeated rows from the database.

I found out how many rows are repeated in table using this query :

SELECT GoodCode FROM Good_

and here is distinct query SELECT Distinct GoodCode FROM Good_

The second one has lower records. Please guide me how I can delete repeated rows from the first one.

Community
  • 1
  • 1
kamiar3001
  • 2,646
  • 4
  • 42
  • 78

2 Answers2

4

Simple method:

SELECT DISTINCT *
INTO   #TempGood
FROM   Good_

TRUNCATE TABLE Good_

INSERT Good_
SELECT *
FROM   #TempGood

DROP TABLE #TempGood
Tim
  • 28,212
  • 8
  • 63
  • 76
0
create table temptable as select distinct * from Good_;
drop table Good_;
rename temptable to Good_;
Jeremy
  • 4,797
  • 1
  • 18
  • 26