how to delete duplicate rows in sql server2005
Answer Posted / arunkumar_mlx
WITH A
AS
(
SELECT ROW_NUMBER() OVER ( PARTITION BY
columnname_1,columnname_2 ORDER BY columnname_1) AS
duplicate FROM table_name
)
SELECT * FROM A WHERE duplicate>1
--DELETE FROM A WHERE duplicate>1
First select and you can find the row_number having more
than 1 rows.
Then delete them on comment of select stmt inside the
query..
decomment of that delete stmt will delete the duplicate
rows.
| Is This Answer Correct ? | 8 Yes | 4 No |
Post New Answer View All Answers
What does it mean if @@cursor_row returns a negative number?
What does the not null constraint do?
How to Update from select query in sql server?
Define tool Manage Statistics in SQL Server 2000 query ?
How do I view a stored procedure in sql server query?
How do you migrate data from mssql server to azure?
What is difference between oltp and olap?
What is the beast way to write CTE in SQL Server ?
What is an index. What are the types?
As per your opinion what are the five top responsibilities of a dba? : sql server database administration
What is the optimization being performed in oracle and SQL Server?
Why it is recommended to avoid referencing a floating point column in the where clause?
What is compound operators?
How to get nth highest salary from employee table.
Explain system views?