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 2008 Forums
 Transact-SQL (2008)
 Findig duplicate using complex key

Author  Topic 

kond.mohan
Posting Yak Master

213 Posts

Posted - 2013-03-02 : 05:43:04
hi,
i have table in sql sever 2008(having count is 15668050),
my table pkey is ACID+ACCT_POA_AS_SRL_NUM+BANK_ID
using this key i want to know the duplicate valuse in the table
i have tried few queries. but i didn't get the solution.-
---
SELECT ACID+ACCT_POA_AS_SRL_NUM+BANK_ID, COUNT(*) TotalCount
FROM abc GROUP BY ACID+ACCT_POA_AS_SRL_NUM+BANK_ID
HAVING COUNT(*) > 1
ORDER BY COUNT(*) DESC
----------

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-03-02 : 06:25:13
[code]
SELECT ACID,ACCT_POA_AS_SRL_NUM,BANK_ID, COUNT(*) TotalCount
FROM abc GROUP BY ACID,ACCT_POA_AS_SRL_NUM,BANK_ID
HAVING COUNT(*) > 1
ORDER BY COUNT(*) DESC
[/code]

if you've pk set via constraint, it will never have duplicate values

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -