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

Do you know what are different types of replication in sql server?

1153


Explain the cursor lock types?

1097


Can you explain full-text query in sql server?

1057


What is the current pricing model of SQL Azure?

104


Difference between 2NF &3NF ?

1131


What is database mirroring?

1173


What are the encryption mechanisms in sql server?

1079


What is the difference between varchar and varchar(max) datatypes?

1133


What is an execution plan?

1234


What types of Joins are possible with Sql Server?

1189


What is a benefit of using an after insert trigger over using a before insert trigger?

1032


How can you manage sql azure security?

105


How to delete duplicate rows from table except one?

1041


How to achieve Paging of records in SQL SERVER?

1140


What is a result set object returned by mssql_query()?

1226