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

how to trace the traffic hitting a sql server? : Sql server database administration

1870


What is the difference between indexing and hashing?

1165


Do you know what is fill factor and pad index?

998


What is a dbms wizard?

1016


What is the difference between sdf and mdf?

1300


How to get a list of columns in a view using "sys.columns" in ms sql server?

985


explain how to create a new schema in a database? : Sql server database administration

1106


What is the difference between substr and charindex in the sql server?

1095


What's new in sql management studio for sql server? : sql server management studio

1063


What are the types of dml?

978


What are xml indexes?

946


Explain the difference between clustered and non-clustered index?

920


Explain the collation?

1103


Explain the usage of floor function in sql server.

959


what is the difference between count(*) and count(1) ?

1081