请进:关于SQL中NULL的一个问题
use ApressFinancial
go
INSERT INTO CustomerDetails.CustomerProducts
(
CustomerId,
FinancialProductId,
AmountToCollect,
Frequency,
LastCollected,
LastCollection
)
VALUES(1,1,100,0,'8/24/2005','8/26/2005')
运行后显示的错误是:不能将值 NULL 插入列 'CustomerFinancialProductId',表 'ApressFinancial.CustomerDetails.CustomerProducts';列不允许有空值。INSERT 失败。
语句已终止。
但是那个 CustomerFinancialProductId 的值我在 VALUES 中已经设为 1
错误在哪里呢? 期望您的回复,非常感谢!!
[解决办法]
系统提示的列名:CustomerFinancialProductId
你指定的是列:FinancialProductId,而不是:CustomerFinancialProductId
[解决办法]
LZ再查查, 估计CustomerFinancialProductId还是没有指定缺省值.
[解决办法]
use ApressFinancial
go
INSERT INTO CustomerDetails.CustomerProducts
(
CustomerFinancialProductId,
CustomerId,
FinancialProductId,
AmountToCollect,
Frequency,
LastCollected,
LastCollection
)
VALUES(1,1,1,100,0, '8/24/2005 ', '8/26/2005 ')
[解决办法]
语句没有问题】
CustomerDetails.CustomerProducts 是表名吗?
其他问题~例~
create table tt(id int,groups nvarchar(10),InActive int)
insert into tt (id,groups,InActive) values(1,1,1)
insert tt select 1,'1',1
[解决办法]
请遵照四颗红星所说改之.
[解决办法]
如果需要自动填充,需要设置为标识列。
设计表,在属性“标识”中选择“是”
[解决办法]
嘿嘿 虚惊一场
[解决办法]
CustomerFinancialProductId列有not null约束,也没有指定default值。insert 语句中没有给这一列赋值。