Wonder how to display or delete duplicate records ? Sometimes, under certain circumstances duplicate data may occur. Then it should be deleted.
In this example, we are going to create a dummy table with an identity column as a unique key, and with two varchar columns. Then we are going to insert data and duplicates manually. The script for the test comes as follow:
create table dummytable(
keycolumn numeric(5,0) identity,
column1 varchar(10),
column2 varchar(10)
)
go
insert dummytable(column1,column2) values("AAA","AAA")
go 10
(1 row affected)
10 xacts:
insert dummytable(column1,column2) values("AAA","BBB")
go
(1 row affected)
insert dummytable(column1,column2) values("BBB","BBB")
go
(1 row affected)
insert dummytable(column1,column2) values("BBB","AAA")
go
(1 row affected)