Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can FK have NULL when PK not NULL?
Message
 
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01547080
Message ID:
01547083
Views:
39
>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.

FK can be NULL. If you want to prevent NULLs in the child table set column to not allow NULLs
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform