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)
 Query help

Author  Topic 

zubairmasoodi
Starting Member

35 Posts

Posted - 2009-10-21 : 07:22:42
Hi all

I have a table with two columns C1 and C2. I need a Query which can check if we have duplicate values for C2 corresponding to any C1 in my table.
Column C1 is Foreign key to a certain table.

thanks in advance

zub

With regards
Zubair Masoodi
(Every day's a school day)

sanoj_av
Posting Yak Master

118 Posts

Posted - 2009-10-21 : 07:53:27
Select col1,col2,count(1) from Table
Group by col1,col2
having Count(1)>1
Go to Top of Page

zubairmasoodi
Starting Member

35 Posts

Posted - 2009-10-21 : 08:24:43
Thanks sanoj

With regards
Zubair Masoodi
(Every day's a school day)

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-10-21 : 12:29:54
should that be

Select col1,count(col2) from Table
Group by col1
having Count(col2)>1
Go to Top of Page
   

- Advertisement -