Click here to Skip to main content
14,111,188 members
Rate this:
 
Please Sign up or sign in to vote.
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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.
   
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web02 | 2.8.190518.1 | Last Updated 14 Nov 2017
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100