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
elnexusAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Andrew_WiegandCommented:
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
0
elnexusAuthor Commented:
But..., if i have foreing keys how can i remove it from SQL Enterprise Manager easily, i could not find a option for this...
0
chigrikCommented:
Read about ALTER TABLE from SQL Server Books online.
It's example:

use AbxData
go

ALTER TABLE ResMetod DROP CONSTRAINT FK_ResMetod_Pet
go


You may drop FK also from diagrams in the Enterprise Manager. (Make diagrams and drop FK)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
elnexusAuthor Commented:
I have no diagrams built but works with the command. Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.