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 are actions, how many types of actions are there, explain with example? : sql server analysis services, ssas
What is a partition key?
Write an sql query for deleting duplicate rows?
Explain something about security and SQL Azure?
What is the difference between functions and stored procedures?
Why should you use or avoid select * statements?
What are indexers?
How can we determine what objects a user-defined function depends upon?
What are sql server procedures?
What is a result set object returned by odbc_exec()?
You want to use bids to deploy a report to a different server than the one you chose in the report wizard. How can you change the server url?
Is it possible for a stored procedure to call itself or recursive stored procedure?
What is meant by Active-Passive and Active-Active clustering setup?
What is the difference between dropping a database and taking a database offline?
How are the exceptions handled in sql server programming?