Is it me be incredibly thick or is it *bloody* hard work getting the simple
Cascade Update/Delete functionality in SQL Server 7 that you take for
granted in Access?

I've searched the www.sqlmag.com site and found this article
http://support.microsoft.com/support/kb/articles/Q142/4/80.asp

I've got three tables in a row with a Parents(PK) - Children(FK) |
Children(PK) - GrandChildren(FK) set of relationships between them. I then
added these two triggers on the Parents and Children tables

CREATE TRIGGER CascadeDeleteChildren ON Parents
FOR DELETE 
AS
DELETE Children
FROM Children, deleted
WHERE Children.ParentID = deleted.ParentID

and

CREATE TRIGGER CascadeDeleteGrandChildren ON Children
FOR DELETE 
AS
DELETE GrandChildren
FROM GrandChildren, deleted
WHERE GrandChildren.ChildID = deleted.ChildID

Trying to delete a record in the Parents table returns this message:


DELETE statement conflicted with COLUMN REFERENCE constraint
'FK_Children_Parents'. The conflict occurred in database 'triggers', table
'Children', column 'ParentID'. The statement has been terminated.


It looks as though the DELETE from Parents is throwing the constraint error
before it's firing the trigger to delete the related records in Children. Do
you enforce referential integrity *either* through constraits *or* triggers,
or is it possible to have both?

Can anyone help, please...? Thanks in advance.


-- 
Aidan Whitehall <[EMAIL PROTECTED]>
Netshopperuk
Telephone +44 (01744) 648650

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to