I have a table EMP in which the values will be like this

EmpId Ename Sal DeptId
11 Ram 10000 10
11 Ram 10000 10
22 Raj 20000 20
22 Raj 20000 20
33 Anil 15000 30
33 Anil 15000 30

I want to delete only duplicate Rows. After Delete I want
the output like this

EmpId Ename Sal DeptId
11 Ram 10000 10
22 Raj 20000 20
33 Anil 15000 30



Answer Posted / shankar

Delete FROM EMP where EMPID in (Select max(EMPID) from EMP
Group by EMPID having Count(EMPID)>1)

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of sign function?

754


What happens if null values are involved in datetime operations?

703


Explain transaction server explicit transaction?

672


Explain system functions or built-in functions? What are different types of system functions?

724


Can sub report data source be different from that of the parent report?

121






How do you drop an index?

676


What guidelines should be followed to help minimize deadlocks?

686


You have a table with close to 100 million records recently, a huge amount of this data was updated now, various queries against this table have slowed down considerably what is the quickest option to remedy the situation?

678


Is it possible to create trigger on views?

710


What are the types of stored procedures in an sql server?

657


When we should use and scope of @@identity?

718


What are click through reports?

118


What is difference between index seek vs. Index scan?

816


Mention a few common trace flags used with sql server?

675


Explain the disadvantages/limitation of the cursor?

710