Duplicate rows occur far too often in databases. Here is a method which is robust and can be used in a variety of duplicate data situations. A create statement for a table of colors with two attributes is given with three duplicate rows.
A CTE is given that creates a separate row number for every key value. If two rows have the same key value, the ones with the row number of 2 or more are deleted in the second part which is the delete statement.Now when we list the entire contents of the table, the duplicates are deleted