Delete duplicate records from the table?(Table must have
unique id)

Answer Posted / brijesh darmwal, sandhya

DELETE FROM [MyDb].[dbo].[sandhya]
WHERE id
IN
(SELECT id
FROM
(SELECT MAX(id) as id,name,addr
FROM [MyDb].[dbo].[sandhya] GROUP BY name,addr having
count(id)>=2)
Tmp)

Is This Answer Correct ?    7 Yes 16 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are various aggregate functions that are available?

691


What is the difference between a stored procedure and a user defined function?

743


What are the different types of join?

789


Explain sql delete command?

790


Explain intellisense for query editing

756






Can we delete data from a view?

706


Your company has 50 branches all over the country all the branches, including the head office have sql server as the database every night all 50 branches upload certain information to the head office which replication topology is best suited for the above scenario?

806


How do I debug a stored procedure in sql server?

726


What is difference between index and primary key?

790


Can we do dml on views?

727


What happens if ntwdblib.dll is missing on your machine?

860


How do you delete a data source?

749


how to avoid cursors? : Sql server database administration

652


What type of Index will get created after executing the above statement?

839


What is a benefit of using an after insert trigger over using a before insert trigger?

722