Query to find duplication in a table

Posted by Kirthiga under Sql Server category on | Points: 40 | Views : 867
create table Test(Nos int,Data varchar)
insert into Test values(1,'A'),(2,'B'),(2,'C'),(3,'D'),(4,'D'),(4,'D'),(5,'E')
select * from Test

--Duplication Checking Query
select Nos,COUNT(*)DupCnt from Test group by Nos having COUNT(*)>1

--Duplication based on two columns
select Nos,Data,COUNT(*)DupCnt from Test group by Nos,Data having COUNT(*)>1

Comments or Responses

Login to post response