消息4104,级别16,状态1,行30多部分标识符" Describe.Product_ID"无法受约束

时间:2018-05-12 04:48:38

标签: sql sql-server

运行此SQL语句:

INSERT INTO Describe (Product_ID, Spec_Category, Spec_Type, Spec_Desc)
    SELECT DISTINCT 
        Products.Product_ID,
        Spec_Category,
        Spec_Type,
        Spec_Desc
    FROM 
        UnknownTable1
    INNER JOIN 
        Products ON Products.Product_ID = Describe.Product_ID

我收到此错误:

  

Msg 4104,Level 16,State 1,Line 30
  多部分标识符" Describe.Product_ID"无法受约束。

这有问题因为外键......任何人都可以解释一下吗?

1 个答案:

答案 0 :(得分:0)

您尚未包含" Describe"选择查询中的表格。您的查询应该是这样的:

INSERT INTO Describe (Product_ID, Spec_Category, Spec_Type, Spec_Desc)
SELECT DISTINCT 
        Products.Product_ID
        ,Spec_Category
        ,Spec_Type
        ,Spec_Desc
FROM UnknownTable1
    INNER JOIN 
        Products
    ON
    Products.Product_ID = UnknownTable1.Product_ID

如果您想添加此Products.Product_ID = Describe.Product_ID条件,则需要在选择查询中加入Describe