ON DELETE CASCADE

ON DELETE CASCADE

 

  

Why do I get the following error when I set up two foreign keys
constraints (two different columns) in the child tables which both
reference the same primary key column in the parent table? If the
parent primary key is changed or deleted the child table should be
updated or set to null in two columns. Is it possible?





USE DotNetNuke
go
ALTER TABLE dbo.FunCam ADD CONSTRAINT FK_FunCam_Reporting1_Users_UserID
FOREIGN KEY (Reporting1)
REFERENCES dbo.Users (UserID)
ON UPDATE CASCADE
go

USE DotNetNuke
go
ALTER TABLE dbo.FunCam ADD CONSTRAINT FK_FunCam_Reporting2_Users_UserID
FOREIGN KEY (Reporting2)
REFERENCES dbo.Users (UserID)
ON UPDATE CASCADE
go







15:39:34.521 DBMS OHSTG2SF -- Error: Introducing FOREIGN KEY
constraint 'FK_FunCam_Reporting2_Users_UserID' on table 'FunCam' may
cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or
ON UPDATE NO ACTION, or modify other FOREIGN KEY
constraints.(42000,1785), Batch 2 Line 1


MS Sql Server LazyDBA home page