sql - multiple cascade paths, on update cascade -
i have problem sql server, when want have 3 table , make relationship between them, , change "on update" property "cascade".
this problem happend when want save diagram:
introducing foreign key constraint 'fk_company_slave' on table 'company' may cause cycles or multiple cascade paths. specify on delete no action or on update no action, or modify other foreign key constraints. not create constraint. see previous errors.
in picture, define data base, fk , ....
thanks.
first:
a foreign key
in 1 table points primary key
in table. if don't want use primary key
on other table in order foreign key, must create unique index on table.
second:
you can create after trigger on master table in order develop on update cascade manually. in other word foreign key between company table , master table created without on update cascade , create following trigger on master update company table after changed row in master table.
create trigger triggername on dbo.[master] after insert begin update company set masterkey = i.masterkey inserted inner join deleted d on d.code = i.code company.masterkey = d.masterkey end
Comments
Post a Comment