Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 does it mean if @@cursor_row returns a negative number?

942


What does the not null constraint do?

998


How to Update from select query in sql server?

993


Define tool Manage Statistics in SQL Server 2000 query ?

1022


How do I view a stored procedure in sql server query?

886


How do you migrate data from mssql server to azure?

165


What is difference between oltp and olap?

980


What is the beast way to write CTE in SQL Server ?

981


What is an index. What are the types?

1010


As per your opinion what are the five top responsibilities of a dba? : sql server database administration

1062


What is the optimization being performed in oracle and SQL Server?

997


Why it is recommended to avoid referencing a floating point column in the where clause?

919


What is compound operators?

974


How to get nth highest salary from employee table.

1102


Explain system views?

1021