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
What are the differences between left join and inner join in sql server?
Can an entity have two primary keys?
How do you debug a procedure in sql server?
What is analysis service repository?
What is the default fill factor value?
What is the advantage of sql server?
What do you mean by an execution plan?
What are the advantages of passing name-value pairs as parameters?
What is the difference between char, varchar and nvarchar?
How raid can influence database performance?
what is the different types of backups available in sql server? : Sql server database administration
What are the different index configurations a table can have?
Explain the different types of backups available in sql server? : sql server database administration
What is data modeling and Reterminal integrity?
What does the on delete cascade option do?