DELETE语句与REFERENCE约束冲突 [英] DELETE statement conflicted with the REFERENCE constraint

查看:574
本文介绍了DELETE语句与REFERENCE约束冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

抛出了类型''System.Web.HttpUnhandledException''的异常。 DELETE语句与REFERENCE约束FK_Table_search冲突。冲突发生在数据库officen_ac7master,表dbo.bc_RefineSearchProducts,列searchID中。

声明已被终止。

怎么解决请帮帮我

Exception of type ''System.Web.HttpUnhandledException'' was thrown.; The DELETE statement conflicted with the REFERENCE constraint "FK_Table_search". The conflict occurred in database "officen_ac7master", table "dbo.bc_RefineSearchProducts", column ''searchID''.
The statement has been terminated.
how it solve please help me

推荐答案

从例外来看,它非常清楚你要删除一个表中的数据,该表在另一个表中有一个引用。



约束是 FK_Table_search 。因此,请检查此约束并找出与其相关的相关表格。



相关列为 searchID



找到与之相关的表后,您需要先删除该相关记录,然后从正在尝试的表中删除。所以,你需要两个DELETE查询。



- >儿童表/相关表的第一个。

- >第二个用于父表。
From the exception, it is quite clear that you are deleting data from one table, which has a reference in another table.

The constraint is FK_Table_search. So check this constraint and find out the related table to which it is related.

The related column is searchID.

After finding the table to which it is related, you need to delete that related record first and then delete from the table you are trying. So, you will need two DELETE queries.

-> First one for Child table/Related table.
-> Second one for the Parent table.


这篇关于DELETE语句与REFERENCE约束冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆