Building a Workflow To-Do List

MSSQL Server – Delete Duplicate Rows – Records

11. June 2011 01:59 by Scott in   //  Tags:   //   Comments (0)

This is how I delete duplicate rows from the database.

DELETE
FROM MyTable
WHERE ID NOT IN
(
SELECT MAX(ID)
FROM MyTable
GROUP BY DuplicateColumn1, DuplicateColumn2, DuplicateColumn3)

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading