Posted By

pauliehaha on 02/09/09


Tagged


Versions (?)

Delete Duplicates PK


 / Published in: SQL
 

  1. -- Deletes duplicates (leaving one instance) where the table has a primary key
  2. DELETE
  3. FROM [TableName]
  4. WHERE [Id] NOT IN
  5. (
  6. SELECT MAX([Id])
  7. FROM [TableName]
  8. GROUP BY [DuplicateColumName1], [DuplicateColumName2]
  9. )

Report this snippet  

You need to login to post a comment.