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
Suppose we have a table "MyTable" containing 10 rows, what query should be executed to update the odd rows "Salary" as 9000?
What is the use of keyword with encryption. Create a store procedure with encryption?
What is exclusive locks?
What are the different kinds of ssrs reports?
What is executereader?
How to drop an existing user defined function in ms sql server?
Explain difference between control flow and data flow?
How can we delete a table in sql server?
Explain what is the difference between a local and a global temporary table?
Is BCNF better than 2NF & 3NF? Why?
Does index slows down insert statements?
How to insert data into an existing table?
How many types of schemas are there?
How many types of built in functions are there in sql server 2012?
whats new about truncate in sql server 2008?