The problem that i have is that i want to disable a trigger of a table on an SQL SERVER 7.0 for a small period of time and then to enable it again. How can i do it?
:confused:
Printable View
The problem that i have is that i want to disable a trigger of a table on an SQL SERVER 7.0 for a small period of time and then to enable it again. How can i do it?
:confused:
This was posted by Brian Knight on SQLServerCentral.com in a script entitled "Quickly Enable/Disable Triggers and Constraints"(for reference):
http://www.sqlservercentral.com/scri...sp?scriptid=25Code:sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
sp_msforeachtable "ALTER TABLE ? DISABLE TRIGGER all"
/*
To enable them back, you can reverse the function. Let's get a
little more creative this time. We'll explicitly set the parameters
and list each table before enabling them so we can verify any
errors easily.
*/
sp_msforeachtable @command1="print '?'", @command2="ALTER TABLE ? CHECK CONSTRAINT all"
sp_msforeachtable @command1="print '?'", @command2="ALTER TABLE ? ENABLE TRIGGER all"
BOL also explains how to do this if you look up triggers and alter table syntax