Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
DURGESH
Posting Yak Master
105 Posts |
Posted - 2008-06-16 : 00:01:24
|
hi all,i have a table that contains duplicate records for an id can anybody help me to write a query to find duplicate recordsthanks in advance durgeshcool |
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-06-16 : 00:08:07
|
select id, (count(*) - 1) as Duplicates from table group by id having count(*) > 1 |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-16 : 02:47:48
|
SELECT IDENTITY(int,1,1) AS Seq,ID,Otherfields...INTO #TempFROM YourTableSELECT t1.*FROM #Temp t1LEFT JOIN (SELECT ID,MIN(Seq) AS MinRec FROM #Temp GROUP BY ID)t2ON t2.ID=t1.IDAND t2.MinRec=t1.SeqWHERE t2.ID IS NULLAND t2.MinRec IS NULLORDER BY t1.ID |
 |
|
|
|
|