i have a primary table that i would like to cascade deletes to 2 other foreign tables in 2 separate relationships. why can't i do this and what are my alternatives?
thank you::Why is it not possible to define more than one relationship per table?
This is possible. You are in error here. read the error message.
::i have a primary table that i would like to cascade deletes to 2 other foreign tables in 2
::separate relationships.
THIS is not possible. You can only have one cascade.
::why can't i do this
Wrong location for this question. Ask the developers.
::and what are my alternatives?
Use a trigger.|||thank you for your response,
in my attempts to use a trigger, i can't seem to get around the error of a subquery returning more than one result. how can you implement a cascading delete with this restriction and/or how do your work around it?
thank you|||Triggers.
And get used to set based operation.
::i can't seem to get around the error of a subquery returning more than one result
What subquery?|||'subquery' refers to the DELETE query in my trigger.
more specifically, i have a DELETE trigger in a primary table. in this DELETE trigger, i have a DELETE query that deletes records in a foreign 'many' table. it is this DELETE query that is the 'subquery' in the error message as listed below;
error message
===============
Server: Msg 512, Level 16, State 1, Procedure triggerMyPrimaryTableDelete, Line 6
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.
===============
trigger code
===============
CREATE TRIGGER triggerMyPrimaryTableDelete
ON dbo.MyPrimaryTable FOR DELETE
AS
BEGIN
DELETE MyForeignManyTable
FROM MyForeignManyTable , deleted
WHERE MyForeignManyTable.ID = deleted.ID
END
===============
thank you
No comments:
Post a Comment