Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ben_53
Yak Posting Veteran
67 Posts |
Posted - 2011-07-28 : 13:48:29
|
| Hi experts,I want to delete the duplicate rows in my table. which has 5 columns.col1 is identity column. I am using the query:DELETE FROM my_table WHERE col1 NOT IN ( SELECT MIN (col1) FROM my_table GROUP BY col2,col3,col4,col5)It deleted many duplicates but not all. Kindly help.Thanks |
|
|
ben_53
Yak Posting Veteran
67 Posts |
Posted - 2011-07-28 : 14:21:33
|
| I used the query that solved the business logic:With cte As(SELECT ROW_NUMBER() OVER (PARTITION BY Col1, Col2, Col3 ORDER BY (SELECT 0)) RNFROM MyTable)DELETE FROM cte WHERE RN<> 1 |
 |
|
|
|
|
|