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 / samba shiva reddy . m

delclare @temp(empname varchar(50),sal int)
select * into @temp
FROM employee
GROUP BY empname, salary
HAVING count(*) > 1
delete from employee
select * into employee from @temp as temp

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Tell me what is difference between view and materialized view?

887


What is “asynchronous” communication in sql server service broker?

962


What are the tool windows in sql server management studio? : sql server management studio

1018


How do you trace the traffic hitting a sql server?

1072


How to get a list all databases on the sql server?

1027


What is role playing dimension with two examples? : sql server analysis services, ssas

954


What is the purpose of self join?

918


What is replace and stuff function in sql server?

999


How many types of dimensions are there and what are they? : sql server analysis services, ssas

1029


How to create a store procedure with encryption?

953


What is policy management?

936


Explain timestamp datatype?

913


What are the limitations in ssrs on sql server express edition?

175


What are the different types of columns types constraints in the sql server?

1012


Explain the disadvantages of cursors?

1053