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 2005 Forums
 Transact-SQL (2005)
 duplicate records

Author  Topic 

pgmr1998
Yak Posting Veteran

66 Posts

Posted - 2008-04-11 : 10:46:18
anybody know what sql statement can be used to pull duplicate records from an sql table.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-11 : 10:49:06
Select col from table
group by col
having count(col)>1

EDIT : Fixed Syntax error

Madhivanan

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

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2008-04-11 : 10:51:37
having count(col)>1



Em
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-11 : 10:53:58
quote:
Originally posted by elancaster

having count(col)>1



Em


Yes it is.
I eidted it

Thanks

Madhivanan

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

pgmr1998
Yak Posting Veteran

66 Posts

Posted - 2008-04-11 : 11:37:54
what is the difference between count(col) and count(*)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-11 : 12:14:39
count(col) looks for the number of occurances of col values while count(*) looks for number of occurances of all the columns in the table. they can be different when col contains many NULL values. count(*) will the total number of rows in the table while count(col) will give total number of non null values in col column.
Go to Top of Page
   

- Advertisement -