且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQL Server外键原因周期或多个级联路径

更新时间:2021-12-04 23:16:26

我找不到更高版本的相应文档,但是

I can't find corresponding documentation for later versions, but the SQL Server 2000 BOL addresses this issue:

由单个DELETE或UPDATE触发的一系列级联引用动作必须形成不包含循环引用的树.在由DELETE或UPDATE导致的所有级联引用动作的列表中,任何表都不能出现多次.级联引用动作的树到任何给定表的路径不得超过一条.当该树的任何分支遇到一个表(未指定操作或为默认操作)时,该分支将终止.

The series of cascading referential actions triggered by a single DELETE or UPDATE must form a tree containing no circular references. No table can appear more than once in the list of all cascading referential actions that result from the DELETE or UPDATE. The tree of cascading referential actions must not have more than one path to any given table. Any branch of the tree is terminated when it encounters a table for which NO ACTION has been specified or is the default.

以后的版本都没有改变.您对此感到犯规:

And later versions haven't changed this. You're falling foul of this:

级联引用动作树不得具有指向任何给定表的多个路径

The tree of cascading referential actions must not have more than one path to any given table

我知道要完成此操作的唯一方法是使用INSTEAD OF触发器而不是使用ON DELETE...来实现B和A之间的级联之一.

The only way I know of to accomplish this is to implement one of the cascades between B and A using an INSTEAD OF trigger, rather than using ON DELETE....

表A和C之间的关系不应该受到任何影响.

The relation between tables A and C shouldn't be impacted by any of this.

( 2008 BOL )