Sunday, February 26, 2012

Enable/Disable Triggers?

Hi all
Is it possible to enable/disable triggers without dropping them'
I want to disbale them sometimes to prevent firing them
thanksLook in the BOL, for the syntax of ALTER TABLE:
ALTER TABLE
(...)
| { ENABLE | DISABLE } TRIGGER
{ ALL | trigger_name [ ,...n ] }
Should do the trick,
HTH, Jens Suessmeyer.|||Yes, I use undocumented stored procedure to do that
-- to diable all
EXEC sp_MSForEachTable N'ALTER TABLE ? DISABLE TRIGGER ALL'
GO
-- to enable all
EXEC sp_MSForEachTable N'ALTER TABLE ? ENABLE TRIGGER ALL'
GO
"perspolis" <rezarms@.hotmail.com> wrote in message
news:%23FzbAHY%23FHA.740@.TK2MSFTNGP12.phx.gbl...
> Hi all
> Is it possible to enable/disable triggers without dropping them'
> I want to disbale them sometimes to prevent firing them
>
> thanks
>|||thanks so much..
Is there any option in SqlServer Enterprise manager to do that visually?/
"Jens" <Jens@.sqlserver2005.de> wrote in message
news:1133776901.386512.272690@.f14g2000cwb.googlegroups.com...
> Look in the BOL, for the syntax of ALTER TABLE:
> ALTER TABLE
> (...)
> | { ENABLE | DISABLE } TRIGGER
> { ALL | trigger_name [ ,...n ] }
> Should do the trick,
> HTH, Jens Suessmeyer.
>|||Although the Procedure still works in SQLServer 2005, you have to keep
in mind that this could be obsolete in further versions.
HTH, Jens Suessmeyer.|||Well, no.|||Be aware of the fact that once disabled, triggers stay disabled for every
connection until re-enabled again. In other words - if the purpose of the
trigger is to enforce a business rule, that rule will not be enforced by the
server during the time the trigger is disabled.
ML
http://milambda.blogspot.com/|||Hopefully by then he will find a solution that doesn't involve disabling
triggers.
"Jens" <Jens@.sqlserver2005.de> wrote in message
news:1133777368.327941.177950@.o13g2000cwo.googlegroups.com...
> Although the Procedure still works in SQLServer 2005, you have to keep
> in mind that this could be obsolete in further versions.
> HTH, Jens Suessmeyer.
>

No comments:

Post a Comment