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 repair damaged sql server mdf file database? In previous day my mdf file has got damage due to unknown reasons then I used dbcc chekcdb command but it failed, MDF file is important for me, I don’ know that how to get back mdf file data. Please anyone suggest me?

1750


Define Business Edition in SQL Azure?

100


Tell me time data type, datetime2, datetimeoffset data type in sql server 2008?

983


Explain aggregate functions?

1083


How to change the name of a database user?

960


What are the requirements to use odbc connections in php scripts?

1120


What are the differences between web role and worker role?

122


What is collation?

1140


What is a data source or ds? : sql server analysis services, ssas

1006


How to get @@error and @@rowcount at the same time?

1035


What is the difference between insensitive and scroll cursor?

1160


How to change the data type of an existing column with "alter table" statements in ms sql server?

982


What is the new security features added in sql server 2016? : sql server security

1116


Explain the etl (extraction, transformation, and loading)?

995


What is the difference between clustered index and primary key?

922