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


Please Help Members By Posting Answers For Below Questions

What are the different acid properties?

620


Define model database?

571


Explain transaction isolation levels in sql server?

545


What is SQL Azure?

85


What is proper subset of candidate key?

555






In case you have filters in your report, when filters will be applied in cached report instance?

78


What type of locking occurs during the snapshot generation? : sql server replication

862


How to delete existing triggers using "drop trigger"?

556


What is a view in sql?

578


How do I start sql server 2016?

525


What is an sql server agent?

542


What are the types of table?

544


How to check what was the last restore transaction LSN in Log shipping or Mirroring? when we don't have a Monitor or witness server.

3370


Explain timestamp datatype?

552


What is resource db in sql server?

593