Let's create a table with duplicate rows in SQL.
create table CustomerDuplicate(customer_id int,customer_name varchar(20))
insert into CustomerDuplicate values(1,'Adam')
insert into CustomerDuplicate values (1,'Adam')
insert into CustomerDuplicate values(2,'Brags')
insert into CustomerDuplicate values(2,'Brags')
insert into CustomerDuplicate values (2,'Brags')
insert into CustomerDuplicate values (3,'Cyrus')
insert into CustomerDuplicate values (3,'Cyrus')
insert into CustomerDuplicate values (4,'David')
One of easiest way to delete the data is on the basis of column that repeat more than once.
Example Query:
delete from CustomerDuplicate where customer_id in(select customer_id from CustomerDuplicate group by customer_id having count(*) >1);
0 Comment(s)