Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Setting Releations
Message
De
30/01/2014 06:32:41
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Maintenance bases de données
Versions des environnements
SQL Server:
SQL Server 2000
Application:
Web
Divers
Thread ID:
01592613
Message ID:
01592614
Vues:
52
>Hi All, I want to create a ( in Fox terms ) relation between two tables in my database , one is Address with a pk of AddressID the other Customer with a foreign key AddressID , many Customers can have the same AddressID , this what I've tried in SSMS
>
>ALTER TABLE address ADD CONSTRAINT FKAddress_Customer FOREIGN KEY
>(
>AddressID
>     
>) REFERENCES Customer(AddressID)
>
>
>but I receive the error
>
>Msg 1776, Level 16, State 0, Line 1
>There are no primary or candidate keys in the referenced table 'customer' that match the referencing column list in the foreign key 'FKAddress_Customer'.
>Msg 1750, Level 16, State 0, Line 1
>Could not create constraint. See previous errors.
>
>the customer AddressID is indexed and not nullable so I don't understand why it doesn't work.

"FOREIGN KEY constraints can reference only columns that are PRIMARY KEY or UNIQUE constraints in the referenced table or columns referenced in a UNIQUE INDEX on the referenced table" - see at http://technet.microsoft.com/en-us/library/ms174979%28v=sql.105%29.aspx

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform