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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 finding duplicates

Author  Topic 

Topaz
Posting Yak Master

199 Posts

Posted - 2008-06-05 : 06:40:03
how can i find duplicates in my database? i want to find them in the website and expressemail field

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-05 : 07:03:25
SELECT website
FROM Table
GROUP BY website
HAVING COUNT(*) >1
Go to Top of Page

Topaz
Posting Yak Master

199 Posts

Posted - 2008-06-05 : 07:47:52
what is the group by function never heard of that?

this just seems to bring up a list of websites that i guess are duplicates. how can it to show me every single duplicate record?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-05 : 07:49:36
quote:
Originally posted by Topaz

what is the group by function never heard of that?

this just seems to bring up a list of websites that i guess are duplicates. how can it to show me every single duplicate record?


Are you using SQL 2005 or sql 2000?
Go to Top of Page

Topaz
Posting Yak Master

199 Posts

Posted - 2008-06-05 : 07:51:55
2005
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-05 : 07:54:10
[code]SELECT *
FROM
(SELECT ROW_NUMBER() OVER(PARTITION BY website ORDER BY PKCol) AS RowNo,
*
FROM YourTable
)t
WHERE t.RowNo>1[/code]
where PKCol is the primary key of your table
Go to Top of Page
   

- Advertisement -