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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Reveal Duplicate Values

Author  Topic 

JonJacobs
Starting Member

2 Posts

Posted - 2010-03-15 : 08:50:13
I need a simple query that reveals duplicate values in a non-indexed column. I'm sure this one is quite simple, but it eludes me.

Select MyColumn From MyTable
Where <more than one occurrance of a value>

Thanks,
Jon Jacobs

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-03-15 : 08:52:05
Select MyColumn,count(*) as DupCounter From MyTable
group by MyColumn having count(*) > 1


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

JonJacobs
Starting Member

2 Posts

Posted - 2010-03-15 : 09:14:47
Thank you very much. I had forgotten all about the having clause.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-03-15 : 09:20:35
You're welcome


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -