问题描述
我有这个创建表脚本
CREATE TABLE Categories (
Id int IDENTITY(1,1) not null,ParentId int null,[Order] int default 0,Published bit not null default 0,Deleted bit not null default 0,CONSTRAINT PK_Categories_Id PRIMARY KEY CLUSTERED (Id),CONSTRAINT FK_Categories_ParentId FOREIGN KEY (ParentId) REFERENCES Categories(Id) on delete cascade,Title nvarchar(255) NOT NULL,CreatedAt DateTime not null default GETDATE(),UpdatedAt DateTime not null default GETDATE()
);
我得到一个错误
Msg 1785,Level 16,State 0,Line 1
Introducing FOREIGN KEY constraint 'FK_Categories_ParentId' on table 'Categories' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION,or modify other FOREIGN KEY constraints.
Msg 1750,State 1,Line 1
Could not create constraint or index. See previous errors.
如何在外键约束上添加删除级联?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)