Duplicate Records

  • How can I delete duplicate records from a table just using a TSQL statement.

    Note : table is not having any primary,unique or Identity column.

    Thanks

  • If the records do not have anything to identify them then you have two options. One add an IDENTITY column to the end and query for the maximum unique value per record and delete all others then remove the column and fix a primary key that will prevent duplicates (it can be all the rows if needed). Or create another table and insert the distinct values from the first table into it, truncate the main table and insert the records that were unique back, then again build a primary kley to prevent future problems.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply