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 / sumathy

Execute the following query for each duplicate value.

1.Delete duplicate of empname='A'

delete top(select count(*)-1 from employee where
empname='A') from employee where empname='A'

2.Delete duplicate of empname='D'

delete top(select count(*)-1 from employee where
empname='D') from employee where empname='D'

Is This Answer Correct ?    9 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is sql server query analyzer?

1093


What is dynamic cursor in SQL SERVER?

1128


What is the difference between composite index and covering index?

1002


What is truncate table?

996


System variable and temporary variables

2295


What are sub reports and how to create them?

144


What are different types of statement?

1081


Can a table have 2 foreign keys?

949


What is 'Join' and explain its various types.

1208


How to select some specific rows from a table in ms sql server?

1051


Explain the difference between cross join and full outer join?

1022


What are the types of user defined functions in sql server?

1092


Difference between drill down and drill through report.

998


What is difference between commit and rollback when used in transactions?

1012


List the advantages of using stored procedures?

1106