运行此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"无法受约束。
这有问题因为外键......任何人都可以解释一下吗?
答案 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