all groups > sql server programming > september 2005 >
You're in the

sql server programming

group:

Avoid triggers in condition


Re: Avoid triggers in condition Jerry Spivey
9/22/2005 4:05:00 PM
sql server programming:
Kirsten,

A trigger can be enabled/disabled for a table by using the ALTER TABLE
statment.

However, TMK, a trigger will always fire when the action that the trigger is
defined for occurs and the trigger is enabled.

HTH

Jerry
[quoted text, click to view]

Re: Avoid triggers in condition Jerry Spivey
9/22/2005 4:18:02 PM
Kirsten,

Use the IF UPDATE (column) AND/OR syntax. See the CREATE TRIGGER statement
in SQL BOL.

HTH

Jerry
[quoted text, click to view]

Avoid triggers in condition Kirsten
9/22/2005 7:57:20 PM
I have a insert/update trigger on MYTABLE.
Is it possible to avoid/deactive this trigger under certain conditions? For
example, when I run a stored procedure.

Any ideas? Maybe setting somekind of temporary variable and unsetting it
after the store proc has run?
Thanks!

Re: Avoid triggers in condition Brian Selzer
9/22/2005 8:10:22 PM
Look up SET CONTEXT_INFO in BOL.

[quoted text, click to view]

Re: Avoid triggers in condition Kirsten
9/22/2005 8:15:58 PM
Ok.
What about if the condition is bases on a column?
For example, how to ask inside the trigger the following?
if only column 4 is updated then do nothing
else do everything.

Thanks!
[quoted text, click to view]

Re: Avoid triggers in condition Hugo Kornelis
9/23/2005 1:05:23 AM
[quoted text, click to view]

Hi Kirsten

ALTER TABLE TableName
DISABLE TRIGGER TriggerName
do something
ALTER TABLE TableName
ENABLE TRIGGER TriggerName

Beware that this will disable the trigger for all connections. If a user
updates the table just when you are running the script, then the trigger
won't fire for him/her either.

A better option is to use the trigger only for code that has to be run
for in ALL circumstances, and put code that is needed only when end
users update the data in the stored procedure they call to make the
modifications.

Best, Hugo
--

Re: Avoid triggers in condition <Moshe>
9/25/2005 12:00:00 AM
Maybe this is what you need:
http://www.aspfaq.com/show.asp?id=2016


[quoted text, click to view]

AddThis Social Bookmark Button