January 31, 2006 at 3:17 am
Hi
How do i find out if there are any duplicate entries in a table?
Thanks in advance
Vij
January 31, 2006 at 3:32 am
You could do something like this:
SELECT field
FROM table
GROUP BY field
HAVING COUNT(field) > 1
February 1, 2006 at 11:09 am
select column1, column2,column3,column4,column5,column6 from tblone where column1 in
(select column1 from tblone
group by column1
having count(column1) > 1)
and
column5 in (select column5 from tblone
group by column5
having count(column5) > 1)
order by column1, column2 asc
In my case if an entry has a different column5 it doesn't count as a duplicate. Please note that this is a brute force method and not necessarily the most efficient.
February 7, 2006 at 7:59 am
another solution:
SELECT field, COUNT(*) AS cnt
FROM dbo.table
GROUP BY field
HAVING (COUNT(*) > 1)
this will displays the field duplicated and how many is duplicated.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply