Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 BREAK or EXIT statement?

Author  Topic 

motokevin
Starting Member

36 Posts

Posted - 2003-03-12 : 19:52:10
I have about 40 triggers in my DB that I want to disable for now...but possibly re-enable in the future. Does anyone know a way to do this?

The best I could come up with is to put
IF 1=0 BEGIN at the beginning of the triggers and END at the end to code around the entire code in the trigger.

Is there some way to just BREAK right at the beginning, or better yet a way to disable and enable the triggers?



tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-03-12 : 19:58:15
Why don't you just delete the triggers, then when you want to use them again just create the triggers again? This is the best way to disable then enable them. Just keep your trigger code handy so that when you want to enable them, you can do it pretty quick.

Tara
Go to Top of Page

byrmol
Shed Building SQL Farmer

1591 Posts

Posted - 2003-03-12 : 20:16:47
Look up the ALTER TABLE statement in BOL. This has an argument to turn off trigger execution.

DavidM

"SQL-3 is an abomination.."
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-03-12 : 20:18:56
quote:

Look up the ALTER TABLE statement in BOL. This has an argument to turn off trigger execution.


Didn't know that could be done. Learn something new everyday!

Tara
Go to Top of Page

motokevin
Starting Member

36 Posts

Posted - 2003-03-13 : 16:34:29
Thanks for the tip David...works like a charm.

Syntax is,

To Disable a single trigger on a table:

ALTER TABLE Table_Name DISABLE TRIGGER Trigger_Name

To Disable all triggers on a table:

ALTER TABLE Table_Name DISABLE TRIGGER ALL

To Enable, just substitute ENABLE for DISABLE and the rest is the same.



Go to Top of Page
   

- Advertisement -