ON DELETE UPDATE CASCADE CONSTRAINT

  • Hello All

    I am dotnet developer

    when i add foreign key constraint for on upadate cascade,on delete cascade then i get this error

    Please Help me to short it out

    Msg 1785, Level 16, State 0, Line 1

    Introducing FOREIGN KEY constraint 'Fk_Dealer_Country' on table 'Dealer' 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, Level 16, State 0, Line 1

    Could not create constraint. See previous errors.

  • It means that two or more foreign keys might result in a loop of mutual deleting. SQL Server can't deal with that (no computer can), so it prevents it by giving you that error.

    If you remove the On Delete Cascade part of the constraint, you can create the constraint.

    If you need chain deletions in that case, you'll need to implement it in the delete proc, or in a trigger.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Does 2008 allow this? If not, is there a way around it without a trigger? Like DeleteOnNull or something like that? I'm trying to convert my oracle database to SQL server and of course, oracle allows this.

    Thanks!!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply