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 to find index size for each index on table?

1001


What is normalization 1nf 2nf 3nf?

1058


How to rebuild the master database?

1076


Which tools are available to manage SQL Azure databases and servers?

115


What do you mean by an execution plan? How would you view it?

912


What will be the maximum number of index per table?

998


What is merge replication?

1103


How to turn on the mssql api module in php?

1072


What are different replication agents and what's their purpose? : sql server replication

1011


How to use subqueries in the from clause in ms sql server?

1159


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

1040


How to configure odbc dsn with different port numbers?

1083


What is nested transaction?

1091


Your company has 50 branches all over the country all the branches, including the head office have sql server as the database every night all 50 branches upload certain information to the head office which replication topology is best suited for the above scenario?

1138


What are the advantages of mirroring?

990