我有一个名为[dbo].[ProductComponentRelationship]
4 个字段的表
[ProductComponentRelationshipID] PK, INt, Not Null
[ProductItemID] FK, Int Not Null
[ComponentItemID] FK, Int, Not Null
[SequenceNumber] int null
该表包含一堆值。我需要更新上表中的 4000 条记录。因此,我用 productItemID 和新的 ComponentitemID 值填充了一个单独的表。我试图运行下面的 sql 语句,但它失败了:
update ProductComponentRelationship set ComponentItemID =
(select compid from cst_pricefix where
ProductComponentRelationship.ProductItemID = cst_pricefix.prditem and
ProductComponentRelationship.ProductComponentRelationshipID = ProductComponentRelationship.ProductComponentRelationshipID )
Error Message:
Msg 515, Level 16, State 2, Line 1
Cannot insert the value NULL into column 'ComponentItemID', table 'SDSDB.dbo.ProductComponentRelationship'; column does not allow nulls. UPDATE fails.