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
Do you know what are different types of replication in sql server?
Explain the cursor lock types?
Can you explain full-text query in sql server?
What is the current pricing model of SQL Azure?
Difference between 2NF &3NF ?
What is database mirroring?
What are the encryption mechanisms in sql server?
What is the difference between varchar and varchar(max) datatypes?
What is an execution plan?
What types of Joins are possible with Sql Server?
What is a benefit of using an after insert trigger over using a before insert trigger?
How can you manage sql azure security?
How to delete duplicate rows from table except one?
How to achieve Paging of records in SQL SERVER?
What is a result set object returned by mssql_query()?