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 is the difference between ddl and dml?
How to delete multiple rows with one delete statement in ms sql server?
How to loop through result set objects using mssql_fetch_array()?
Can you explain full-text query in sql server?
Do you know what are acid properties?
Define model database?
What encryption security is available in sql azure?
Which are the two editions in which SQL Azure database available?
Why do we need different type of parameter?
how many no of arguments can be passed in procedures and functions
Why is sql server log file full?
How to convert binary strings into integers in ms sql server?
What is the sql case statement used for? Explain with an example?
What is transactional replication?
Explain how to maintain a fill factor in existing indexes?