Write a query to delete duplicate records in SQL SERVER

Answer Posted / saurabh dixit

DECLARE @people TABLE
(
name VARCHAR(32),
age INT
)
insert into @people
select Name,age From People group by Name,Age having COUNT(name)>1

delete People from People pe
join @people p on pe.name=p.name and pe.age=p.age

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to add additional conditions in SQL?

590


What is index fragmentation in ms sql server?

606


Explain how you can deploy an SSRS report?

106


What is a functions and types in sql server?

598


How to create a scrollable cursor with the scroll option?

502






What is the syntax for encrypting a column in SQL Server?

559


How to create an index on an existing table in ms sql server?

499


What are the types of indexing?

600


Do you know what is normalization of database? What are its benefits?

562


How to find related tables in sql server?

501


Is it possible to replicate data from sql server to oracle? : sql server replication

549


How to create view in stored procedure sql server?

507


In which sql server version report builder introduced?

105


if no size is defined while creating the database, what size will the database have? : Sql server administration

550


Explain alternate key, candidate key and composite key in sql server?

524