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...

Delete duplicate rows from a table without primary key by
using a single query
Table Employee
empname salary
A 200
B 300
A 200
C 400
D 500
D 500

Output should be

A 200
B 300
C 400
D 500

Answer Posted / devender kumar

This query is for sql server 2005 and higher version of sql
server. It will not run on older versions.



with myCTE as(
select row_number() over( partition by empname order by
empname) as myCount from Employee
)delete from myCTE where myCount >3

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I install sql server?

935


What are the advantages of having an index on the sql server?

973


What are key constraints?

1014


What is a group function explain with an example?

1031


What are the steps to process a single select statement?

986


Are there any preferred steps that need to be taken care of before starting the installation of sql server 2000?

1028


How to retrieve field values using mssql_result()?

1411


How to use “drop” keyword in sql server and give an example?

1187


Explain about merge replications?

1075


What is raid, and how it can influence database performance?

1097


What is database white box testing?

1173


What is a linked server in sql server?

1129


What is the current limitation of the size of SQL Azure DB?

129


What is blocking?

1128


How to get a list of columns in a view using the "sp_help" stored procedure?

1085