Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have composite keys in my table ( group of primary keys) & assigned not null to them,
but the problem is coming while data pushing, one column having null value but he is giving me error :
Cannot insert the value NULL into column 'DEPARTMENT_ID', table 'dbo.ACCOUNT'; column does not allow nulls. UPDATE fails.
The statement has been terminated.
...how to push data of null values

What I have tried:

i tried to push data but due to primary key, he is not accepting null value
Posted
Updated 13-Nov-17 22:28pm

1 solution

If the column does not allow nulls - and a Primary Key column can't because values must be unique - then you cannot insert a null value; that is what the error message is saying.

The same thing applies to composite primary keys: they cannot contain null values either, because all parts are compared and NULL does not compare to NULL:
SELECT CASE WHEN NULL = NULL THEN 'YES' ELSE 'NO' END
Will always give you the result "NO".

You cannot use a NULL value in any part of a composite primary key.
 
Share this answer
 
v2
Comments
Member 12224208 14-Nov-17 4:50am    
so any option to push data?
OriginalGriff 14-Nov-17 5:10am    
Not if it's NULL.

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