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
 Transact-SQL (2000)
 Finding duplicate entries

Author  Topic 

maldoiv
Starting Member

1 Post

Posted - 2005-07-26 : 22:05:59
Does anyone have a script that will find duplicate entries in one table. The table is setup like this:

Eff_Date Unit# Company_Name

I need to search the entire table either by eff_date, unit# or company_name, if possible by all three.

Can anyone help?

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2005-07-26 : 23:13:00
To find dupes, just do this:
SELECT Eff_Date, Unit#, Company_Name
FROM yourTable
GROUP BY Eff_Date, Unit#, Company_Name
HAVING Count(*) > 1

This will find duplicates across all columns. For individuals:
SELECT Company_Name
FROM yourTable
GROUP BY Company_Name
HAVING Count(*) > 1

HTH,

Tim

Go to Top of Page
   

- Advertisement -