开发者

Self referencing Foreign Key SQL Server DeleteAction does nto work

开发者 https://www.devze.com 2023-03-09 11:43 出处:网络
I have one Table with a self referencing foreign key with DeleteAction set to Cascade, but when Parent is deleted,no children (direct or descendant) does not delete.

I have one Table with a self referencing foreign key with DeleteAction set to Cascade, but when Parent is deleted,no children (direct or descendant) does not delete.

What a开发者_JAVA百科m I missing ?


You cannot use cascade delete on self referencing tables.

Check this link for possible solution.


For use delete cascade use following Create table script...

CREATE TABLE

test_child

( SUB1 INT, [NO] int, FOREIGN KEY ([NO]) REFERENCES Test_parent ON DELETE CASCADE )

Check This link for more information:

http://msdn.microsoft.com/en-us/library/ms186973.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消