disable a trigger
i have a trigger in which i placed the following flag parameter to enable or disable trigger
SELECT @ENABLETRIGGER = AP_VALUE_TERM FROM local.APP_PARAMETERS WHERE AP_NAME LIKE 'Enableemployees_TRIGGER'
IF(@ENABLETRIGGER = 'Y')
now i want to disable a trigger temporarily and enable it again.
the alter table 'table name' disable trigger'triggername'
isnt working for me.
can someone suggest an update statement to the trigger where i change the flag to 'N' so that the trigger is disabled and later update the flag back to 'Y' so that the trigger is enabled.
thanks
justin
December 21st, 2010 6:41pm
can someone suggest an update statement to the trigger where i change the flag to 'N' so that the trigger is disabled and later update the flag back to 'Y' so that the trigger is enabled.
Based on the trigger code snippet you posted, it looks to me like a simple update statement like the examples below should do the job. ALTER TABLE...DISABLE TRIGGER should work too.
--disable trigger
UPDATE local.APP_PARAMETERS
SET AP_VALUE_TERM = 'N'
WHERE AP_NAME = 'Enableemployees_TRIGGER';
--enable trigger
UPDATE local.APP_PARAMETERS
SET AP_VALUE_TERM = 'Y'
WHERE AP_NAME = 'Enableemployees_TRIGGER';
Dan Guzman, SQL Server MVP, http://weblogs.sqlteam.com/dang/
Free Windows Admin Tool Kit Click here and download it now
December 21st, 2010 8:52pm
this is the one im lookin for , this works fine but one more thing i have 4 triggers and i get an error when i write the code the following way
UPDATE local.APP_PARAMETERS
SET AP_VALUE_TERM = 'N'
WHERE AP_NAME = 'Enableemployees_TRIGGER','Enablestaff_TRIGGER','Enableadmin_TRIGGER','Enableother_TRIGGER';
--enable trigger
UPDATE local.APP_PARAMETERS
SET AP_VALUE_TERM = 'Y'
WHERE AP_NAME = 'Enableemployees_TRIGGER','Enablestaff_TRIGGER','Enableadmin_TRIGGER','Enableother_TRIGGER';
where so you think im goin wrong
thanks
December 22nd, 2010 10:45am
Change your WHERE statements...
UPDATE local.APP_PARAMETERS
SET AP_VALUE_TERM = 'N'
WHERE AP_NAME IN ('Enableemployees_TRIGGER','Enablestaff_TRIGGER','Enableadmin_TRIGGER','Enableother_TRIGGER');
--enable trigger
UPDATE local.APP_PARAMETERS
SET AP_VALUE_TERM = 'Y'
WHERE AP_NAME IN ('Enableemployees_TRIGGER','Enablestaff_TRIGGER','Enableadmin_TRIGGER','Enableother_TRIGGER');
HTH,
JasonJason Long
Free Windows Admin Tool Kit Click here and download it now
December 22nd, 2010 11:54am