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 are actions, how many types of actions are there, explain with example? : sql server analysis services, ssas

1016


What is a partition key?

945


Write an sql query for deleting duplicate rows?

992


Explain something about security and SQL Azure?

134


What is the difference between functions and stored procedures?

1150


Why should you use or avoid select * statements?

1014


What are indexers?

1077


How can we determine what objects a user-defined function depends upon?

989


What are sql server procedures?

967


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

1014


You want to use bids to deploy a report to a different server than the one you chose in the report wizard. How can you change the server url?

155


Is it possible for a stored procedure to call itself or recursive stored procedure?

939


What is meant by Active-Passive and Active-Active clustering setup?

1158


What is the difference between dropping a database and taking a database offline?

1164


How are the exceptions handled in sql server programming?

1054