Itzik Ben-Gan and Thomas Moreau have some examples of cascading RI triggers
in their white paper:
<
http://www.msdn.microsoft.com/librar...y/en-us/dnsql2
k/html/sql_refintegrity.asp?frame=true>.
The main consideration is that you cannot have declarative referential
integrity in place when you perform cascading actions in triggers in SQL 7,
..
--
Hope this helps.
Dan Guzman
SQL Server MVP
"Aidan Whitehall" <aidanwhitehall@fairbanks.co.uk> wrote in message
news:btph6b$kri$1@sparta.btinternet.com...[color=blue]
> Have gone through BOL and Google, but can't find the answer... please help
> with a simple Q. I'm trying to create a simple cascade delete trigger in[/color]
SQL[color=blue]
> Server 7 where deleting "parent" records in table X delete corresponding
> child records in table Y.
>
> Table X
> =========
> X_ID
> SOME_VAL
>
> Table Y
> =========
> Y_ID
> X_ID
> SOME_VAL
>
>
> When there is no relationship between X.X_ID and Y.X_ID, the following
> trigger works fine:
>
> CREATE TRIGGER "temp" ON x
> FOR DELETE
> AS
>
> delete
> from y
> where x_id in (select x_id from deleted)
>
> However, when a relationship is created to enforce referential integrity,
> the trigger fails, with a "DELETE statement conflicted with COLUMN[/color]
REFERENCE[color=blue]
> constraint" error. I've seen examples where the trigger says (for example)
> "AFTER INSERT", where presumably the code is specifically run after the
> event that triggers it -- is there a way of forcing the trigger to run
> before the delete from table X is executed? I've tried using "BEFORE
> DELETE", but no dice :-\
>
>
> Thanks!
>
> --
> Aidan Whitehall <aidanwhitehall@fairbanks.co.uk>
> Macromedia ColdFusion Developer
> Fairbanks Environmental Ltd +44 (0)1695 51775
>
>[/color]