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
 Counting duplicates

Author  Topic 

bronsonr33
Starting Member

1 Post

Posted - 2007-05-03 : 11:21:57
Hi, I'm attempting to write a small query that will search all entries in a colum and compair their values to see if there are any duplicates, then display only the duplicate entries. I'm running into trouble when using ms sql 2000 in that it does not like the COUNT statement. Any ideas?

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-05-03 : 11:23:21
Probably it is the way you wrote COUNT() is not acceptable to the SQL Server. Post the query here so that we can help you further.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-05-03 : 11:26:57
select yourDuplicatedColumn
from your table
group by yourDuplicatedColumn
having count(yourDuplicatedColumn) > 1

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-05-04 : 00:31:00
You need to learn SQL
Search for "Learn SQL" in this forum

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

pbguy
Constraint Violating Yak Guru

319 Posts

Posted - 2007-05-04 : 00:39:21
Spirit1's query is the way to find the duplicate entries in the table
Go to Top of Page
   

- Advertisement -