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 disable triggers using "disable trigger"?

556


You notice that the transaction log on one of your databases is over 4gb the size of the data file is 2mb what could cause this situation, and how can you fix it?

638


Explain transaction server implicit?

516


Please explain the characteristics of a transaction server for example atomicity, consistency, isolation, durability?

494


What is a join in sql?

581






mention different types of relationships in the dbms?

501


Explain the first normal form(1nf)?

555


How to make conditional sum in ssrs?

131


What is the use of sign function?

555


What are dml (data manipulation language) statements in ms sql server?

547


Why truncate is ddl?

606


what are isolation levels? : Sql server database administration

495


How to name query output columns in ms sql server?

536


What are the components of sql server service broker?

507


How to select true false based on column value in sql server?

504