我的数据库中有两个表,t1表主键是uid,t2表外键名称desg。现在我想删除或更新一个表中的此 uid,但出现错误
Now row was updated. data in the row was not committed. error source:.netSqlclient data provider. error message: the update statement conflicted with the reference constraint fk_t2_t1.the conflict occur in the database DBname, dbo.t2,column desg. the stsement has been terminated.
当我尝试删除时,它会显示此消息。
executed SQl statement: delete from t1 where uid='abc'
error source:.netSqlclient data provider. error message: the Delete statement conflicted with the reference constraint fk_t2_t1.the conflict occur in the database DBname, dbo.t2,column desg. the stsement has been terminated.
请告诉我如何进行此更新和删除。
我是这个领域的新手,需要帮助,谢谢。
最佳答案
首先删除t2表的外键
然后删除t1表的主键是uid
。这不会起作用,反之亦然
关于sql-server - 从具有外键约束的两个表中删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3815674/