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

How to filter out duplications in the returning rows in ms sql server?

650


How to add additional conditions in SQL?

594


What is the difference between a clustered index and a non-clustered index?

538


Is it possible for a stored procedure to call itself or recursive stored procedure? How many levels of sp nesting are possible?

524


How to create a user to access a database in ms sql server using "create user" statements?

532






What is a constant or literal in ms sql server?

605


What is rank function?

612


Explain different types of lock modes in sql server 2000?

537


What are the different types of sql server replication? : sql server replication

630


When we should use and scope of @@identity?

561


What are the encryption mechanisms in sql server?

590


What is the server name in sql server?

567


What is the full meaning of dml?

534


How to select all columns of all rows from a table with a select statement in ms sql server?

582


How to list all tables in the database using odbc_tables()?

574