Hi ,
I have below requirement to produce report:-
Need to check the each table for uniqueness of the primary key, If the Key is not unique need to display those keys else need to display "No Duplicates"
I found out the below Query which finds the Duplicate Keys but I want Non Duplicate Keys should be displayed with message "No Duplicates"
SELECT 'DEPOSITOR_UNIQUE_ID', --> This is the Primary key in table1(It can accept duplicate keys)
DEPOSITOR_UNIQUE_ID
FROM table1
GROUP BY DEPOSITOR_UNIQUE_ID
HAVING COUNT(*) > 1
Report should be something like below,
-----------------------------------------------------------
TableName----+----Primary Key----+------Duplicate
-----------------------------------------------------------
Table1 + Depositor unique ID + No duplicates
Table2 + Depositor unique ID + No duplicates
Table3 + Account unique ID + CDA000003010395890000000000000000
................................ + CDA000660001350416000000000000000