0
我有如下表:SQL服务器的外键约束错误
CREATE TABLE [dbo].[Comment]
(
[CommentID] INT NOT NULL PRIMARY KEY,
[CommentContent] NVARCHAR(MAX) NULL,
[CommentDateTime] DATETIME2 NULL,
[ArticleID] INT NULL,
[ResponseTo] INT NULL,
CONSTRAINT [FK_dbo.Comment_dbo.Article_ArticleID]
FOREIGN KEY ([ArticleID])
REFERENCES [dbo].[Article] ([ArticleID]) ON DELETE CASCADE,
CONSTRAINT [FK_dbo.Comment_dbo.Comment_ResponseTo]
FOREIGN KEY ([ResponseTo])
REFERENCES [dbo].[Comment] ([CommentID]) ON DELETE CASCADE
)
而且我得到这个错误有关无法创建约束:
Error: SQL72014: .Net SqlClient Data Provider:
Msg 1785, Level 16, State 0, Line 1
Introducing FOREIGN KEY constraint 'FK_dbo.Comment_dbo.Comment_ResponseTo' on table 'Comment' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
它说,一些有关周期.. 。 我如何解决它?
TL; DR,如何解决这个问题?去除'CASCADE'? – VSG24