Link to home
Start Free TrialLog in
Avatar of elnexus
elnexus

asked on

MODIFY CONSTRAINTS

I want modify relation between tables, in the next way: i just wanna delete this relation. Why that: when i delete a record, i launch a trigger that updates all tables where this record is envolved, but i get the next message:

DELETE statement conflicted with COLUMN REFERENCE constraint 'FK_ResMetod_Pet'. The conflict occurred in database 'AbxData', table 'ResMetod', column 'Pet'.

Hope somebody can help me.
thanks
Avatar of Andrew_Wiegand
Andrew_Wiegand

Hi,
Your problem is when you issue your delete SQL Server checks for constraint violations before it executes the trigger.  So your trigger never even gets fired.  This is a common problem.  You have 2 options for enforcing pk-fk relationships:
1.  triggers or
2.  pk-fk constraints

You can't do both.  If you want to enforce referential integrity using triggers then you cannot define primary key and foreign key constraints on the columns.

hth,
andrew
Avatar of elnexus

ASKER

But..., if i have foreing keys how can i remove it from SQL Enterprise Manager easily, i could not find a option for this...
ASKER CERTIFIED SOLUTION
Avatar of chigrik
chigrik

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of elnexus

ASKER

I have no diagrams built but works with the command. Thanks