Click here to Skip to main content
14,695,235 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
I want to avoid duplication of data suppose i have a table name Schema_tbl that holds 2 coloums
Schema_tbl columns are :
tblNames | primaryKeysCol
data:
tblCustomer | cmpid
tblCustomer | brchid
tblCustomer | pkid
--duplicated values --
tblCustomer | cmpid

now how to make a composite key that avoids the duplicated of data in primary key coloumns agains composite key

What I have tried:

NOTHING ONLY DEVELOPED SCHEMA I GOOGLED BUT FOUND SOLUTION THAT COMPOSITE KEYS WILL BE APPLIED BUT HOW TO
Posted
Updated 14-Jul-16 0:24am
v2

1 solution

Try-
ALTER TABLE Schema_tbl
    ADD CONSTRAINT pk_myConstraint PRIMARY KEY (tblNames,primaryKeysCol)


Hope, it helps :)
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900