Friday, March 30, 2012

Remove duplicate rows from a table

Hi guys

I have been using SQL server 2005. I have got a huge table with about 1 million rows.

Problem is this table has got duplicate rows in lot of places. I need to remove the these duplicates. Is there an easy way to do that?

Is there a query in SQL to remove duplicate rows?

thanks

Mita

Mita:

I would start by modifying the table so that it becomes impossible to have duplicate rows. That is, you want to make it so that no two rows will ever be exactly identical. By doing this you will always have a method of selecting records according to the property that makes them unique. The easiest ways to make table rows unique are to use either (1) an identity column or (2) a unique identifier column. Look in books online for a discussion. Once you have a method of keying your records you will be able to delete records according to this record key.


Dave

|||

Hi,

refer below threads discussing same topic

http://www.sql-server-performance.com/forum/topic.asp?TOPIC_ID=3632

http://www.sql-server-performance.com/forum/topic.asp?TOPIC_ID=18529

http://www.sql-server-performance.com/forum/topic.asp?TOPIC_ID=14484

http://www.sql-server-performance.com/forum/topic.asp?TOPIC_ID=13882

Hemantgiri S. Goswami

No comments:

Post a Comment