Write a query to delete duplicate records in SQL SERVER

Answer Posted / sonia

Create table info(comp_id int identity(101,1),comp_name
varchar(50))
insert into info values('Progressive Ltd.')
insert into info values('Progressive Ltd.')
insert into info values('EliResearch')
insert into info values('Patni')
insert into info values('Accenture')
insert into info values('Accenture')
select * from info

DELETE FROM info
WHERE comp_name IN
(SELECT comp_name FROM info
GROUP BY comp_name HAVING COUNT(comp_name) > 1)

Is This Answer Correct ?    12 Yes 38 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does set rowcount do?

514


What is the maximum number of instances in 32 bit and 64 bit sql server 2012?

534


Explain filtered indexes benefits?

594


What are the different types of backups that exist?

682


You want to implement the one-to-many relationship while designing tables. How would you do it?

508






Which is better statement or preparedstatement?

526


What are different types of roles provided by ssrs?

112


Is truncate autocommit?

563


Explain the phases a transaction has to undergo?

558


How can I add Reporting Services reports to my application?

91


What does it mean to invest in the index?

511


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

546


What are temporal tables in sql server 2016?

479


Difference between DELETE and TRUNCATE?

617


Different types of keys in SQL?

634