Write a query to delete duplicate records in SQL SERVER

Answer Posted / deepak raheja

DELETE FROM A
WHERE (id NOT IN
(SELECT MAX(ID)
FROM A
GROUP BY name))

suppose i have table called A. A has two coloumn id
(identity) as int and Name as nvarchar. I have data like
this.

id Name
1 C
2 D
3 C
4 E
5 D
6 D

Is This Answer Correct ?    78 Yes 57 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to enter unicode character string literals in ms sql server?

577


What is meant by dirty read?

558


What are extended events in sql server?

508


What is ddl and dml commands?

513


What is use of attribute hierarchy optimized state? : sql server analysis services, ssas

588






Does index slows down insert statements?

586


What do I need to start working with sql studio? : sql server management studio

593


Do you know the cursor optimization tips?

590


What is server-level principal?

100


Explain Reporting Life Cycle?

90


You are designing a database for your human resources department in the employee table, there is a field for social security number, which cannot contain null values if no value is given, you want a value of unknown to be inserted in this field what is the best approach?

625


What are filegroups in sql server?

582


How do I start sql server 2016?

525


What are the different types of triggers in SQL SERVER?

541


What is efficiency data?

527