Write a query to delete duplicate records in SQL SERVER

Answer Posted / shashank shrivastava

Table-admin
------------------
adminID adminName
1 admin
2 tester
3 admin

SQL:
---------------
DELETE admin.* FROM admin,
(SELECT count(adminName) as c, MAX(adminID) as m from
admin GROUP BY adminName HAVING c>1) as new_admin
WHERE admin.adminID=new_admin.m

Is This Answer Correct ?    1 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can a table be moved to different filegroup?

574


What is an indice?

577


Can you import Microsoft Excel data to SSRS?

89


What is federation member?

93


Explain active/passive and active/active cluster configurations?

632






What is a self join in sql server?

602


How to choose all records from the table?

659


How do I start sql server agent automatically?

504


What happens if null values are involved in comparison operations?

547


When is update_statistics command used?

587


What is difference between unique and primary key?

480


How many columns can exist together per table?

709


How do I view a stored procedure in sql server query?

541


Define inner join in sql server joins?

535


Explain different types of Normalization.

601