我的查询下面给出 '与FK约束冲突':SQL Server 2008中 - 无法插入由于
insert into Orders
values
('20012', /*order num, pk*/
'6-10-2012', /*date, i wrote it in a different format, is that okay ?*/
'1000000012'/*customer id, fk*/
)
错误:
The INSERT statement conflicted with the FOREIGN KEY constraint
"FK_Orders_Customers".
The conflict occurred in database "MyDB", table "dbo.Customers", column 'cust_id'.
The statement has been terminated.
为什么我得到这个错误?我怎样才能将一些虚拟值插入此表中?
你确定1000000012存在,它是TEXT? – xQbert
@xQbert - 我认为你的意思是一个字符串而不是'TEXT'(这是一个废弃的大对象数据类型的名称)。虽然引号不需要/不应该在那里,如果该列实际上是数字SQL Server会隐式转换'1000000012'无论如何。 –