how to delete duplicate rows in sql server
How can i delete duplicate rows where no unique row id exists?
My table is
col1 col2 col3 col4 col5 col6 col7
john 1 1 1 1 1 1
john 1 1 1 1 1 1
sally 2 2 2 2 2 2
sally 2 2 2 2 2 2
I want to be left with the following after the duplicate removal
john 1 1 1 1 1 1
sally 1 1 1 1 1 1
Ive tried a few queries but i think they depend on a rowId as i dont get
desired result, for example
DELETE FROM table WHERE col1 IN (
SELECT id FROM table GROUP BY id HAVING ( COUNT(col1) > 1 )
)
No comments:
Post a Comment