Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can FK have NULL when PK not NULL?
Message
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Titre:
Can FK have NULL when PK not NULL?
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01547080
Message ID:
01547080
Vues:
55
Hi,

I have been testing the following scenario:

Parent table has PK Integer. This key cannot have NULL; this is an Identity column.
Child table has FK with the constraint set to the PK of the parent. If I set a value of this FK of one of the rows to NULL, I get no error. I thought that because the constraint requires that FK has to have a value in the parent table and the parent table has no NULL values, I should get an error. But I don't. What am I missing? TIA.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform