无法插入表格的某些列 [英] Not able to insert into certain columns of the table

查看:95
本文介绍了无法插入表格的某些列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将数据插入到我的表的某些列中,并且我一直收到以下错误消息。



I am trying to insert data into certain columns of my table and i keep getting the below error message.

Cannot insert the value NULL into column 'RKEY', table 'Test-Live.dbo.tempWIPAeroV1'; column does not allow nulls. INSERT fails.





我甚至不想在RKEY专栏中输入任何内容



我尝试过:





I am not even trying to enter anything in the RKEY column

What I have tried:

<pre> Insert into tempWIPAeroV1 (WIPMATL,WIP_sold) (select Material_cost ,Sold_cost  from NewValues  join tempWIPAeroV1 on  tempWIPAeroV1.RKEY = NewValues.RKEY )

推荐答案

表中的RKey列不允许使用NULL值。

当您插入新记录时不提供此字段的值,数据库将值设置为NULL。



因此您有3个选项;

a)编辑接受NULL值的字段如下

1)打开SQL企业管理器

2)右键单击表&选择设计

3)滚动到列&勾选Allow Nulls字段

4)关闭表格 - 提示保存时单击是

b)设置字段的默认值

1 )打开SQL企业管理器

2)右键单击表&选择设计

3)选择正确的列

4)根据字段类型设置默认值或Binding字段

5)关闭table - 提示保存时单击Yes

c)更新您的Insert语句如下(仅示例)

The column RKey in your table does not allow a NULL value.
When you insert a new record & do not provide a value for this field, the database will set the value to NULL.

Therefore you have 3 options;
a) Edit the field to accept a NULL value as follows
1) Open SQL Enterprise Manager
2) Right-click the Table & select Design
3) Scroll to the column & tick the Allow Nulls field
4) Close the table - click Yes when prompted to save
b) Set a Default value for the field
1) Open SQL Enterprise Manager
2) Right-click the Table & select Design
3) Select the correct column
4) Set the Default value or Binding field based on the field type
5) Close the table - click Yes when prompted to save
c) Update your Insert statement as below (example only)
Insert into tempWIPAeroV1 (WIPMATL,WIP_sold, RKey) (select Material_cost ,Sold_cost, RKEY  from NewValues  join tempWIPAeroV1 on  tempWIPAeroV1.RKEY = NewValues.RKEY )





亲切的问候



Kind Regards


INSERT INTO tempWIPAeroV1 (WIPMATL,WIP_sold, RKey)
                (SELECT Material_cost ,Sold_cost,ISNULL(tempWIPAeroV1.RKEY,'') AS RKey  
                 FROM NewValues
                 LEFT JOIN tempWIPAeroV1 ON  (tempWIPAeroV1.RKEY = NewValues.RKEY) );


这篇关于无法插入表格的某些列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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