Home All Groups Group Topic Archive Search About

Cascading Triggers Part II

Author
23 Sep 2005 12:57 PM
Michael Maes
Hi,

Since Allowing Nested Triggers is DataServer-Wide, it is quite dangerous to
"depend" on it. In Fact, someone (or some program) might turn them on/off...

Is it therefore a good practice to include a Checking SP in every Trigger
you're aware off that might invoke a cascading action?

I want to do something like this:


-- Get Original State
DECLARE @NestedTriggersOn_Original bit

SET @NestedTriggersOn_Original =
    (
    SELECT  [value]
    FROM    master.dbo.sysconfigures
    WHERE    config =
        (
        SELECT number As config
        FROM master.dbo.spt_values
        WHERE [name] = 'nested triggers'
            AND type='C'
        )
    )

IF @NestedTriggersOn_Original = 0

    BEGIN
        EXEC sp_configure 'nested triggers', 1
        RECONFIGURE

    END


/*
    RUN TRIGGER
*/


-- Restore Original State
IF @NestedTriggersOn_Original = 0

    BEGIN
        EXEC sp_configure 'nested triggers', 0
        RECONFIGURE

    END

Or is this "Overkill"?
Is there a better way?

TIA,

Michael

AddThis Social Bookmark Button