数据推送非空列时出现问题? [英] Problem while data push on not null columns?

查看:56
本文介绍了数据推送非空列时出现问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表中有复合键(主键组)&分配给它们不为空,

但问题是在数据推送时出现,一列有空值但他给我错误:

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.

...如何推送空值数据



我试过的:



i尝试推送数据,但由于主键,他不接受空值

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

推荐答案

如果列不允许空值 - 并且主键列不能,因为值必须是唯一的 - 那么您不能插入空值;这就是错误消息所说的。



同样的事情适用于复合主键:它们也不能包含空值,因为所有部分都被比较而NULL不是比较为NULL:

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

总是会给你结果NO。



您不能在复合主键的任何部分使用NULL值。

Will always give you the result "NO".

You cannot use a NULL value in any part of a composite primary key.


这篇关于数据推送非空列时出现问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆