October 21, 2003 at 7:42 am
Is there a good way to disable triggers on a table for a specific SP? When I run sp_xyz which updates 1 table, I want the triggers on the table not to fire. I want them to fire on all other updates and inserts.
Thanks!
October 21, 2003 at 8:05 am
October 22, 2003 at 1:07 am
Hi.
Yes u can achieve this.
What I wld like to suggest u is that use this statement as the statement before u r firing the update query.
alter table tablename disable trigger triggername
then fire the update query
and then again enable the trigger
alter table tablename enable trigger triggername
Hope that Solves ur Problem.
Gaurav Gupta
Database Developer
Advent Matrix Inc
.........
.........
October 22, 2003 at 2:53 am
quote:
tablename disable trigger triggernamethen fire the update query
and then again enable the trigger
alter table tablename enable trigger triggername
won't that disable the trigger for ALL updates rather than just for that proc?
surely a less bad way would be to add a column to the table which would hold procName or procId and test for that in the trigger...
October 22, 2003 at 3:06 am
Using the alter table ???? disable trigger ???? is totally crap. Shouldn't the trigger fire when some other procedure executes for which it SHOULD fire?
I have implemented the same effect by using login name of the user in whose context this trigger might fire. If it matches the name for which i do not want it to fire, the trigger just exits. My requirements were simple so I went for login name, but the idea of creating role is even better and flexible.
October 22, 2003 at 8:37 am
Here's the final post in the thread that Jonathan referenced.
quote:
For us it is a dead issue now. The developers are going to do some upfront validation which will eliminate the need for the trigger in question.
I think this is the best approach, if at all possible.
October 23, 2003 at 6:15 am
Thanks for the replys guys. I think I'm going to go with the context idea in the link on the first reply. I can't change the table and don't have control over the app that writes to the table to be able to get rid of the trigger.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply