943,739 Members | Top Members by Rank

Ad:
  • MS SQL Discussion Thread
  • Unsolved
  • Views: 4617
  • MS SQL RSS
Jun 30th, 2009
-1

Update table row without firing trigger?

Expand Post »
I have a INSERT, UPDATE trigger on a table, it works great and helps me from firing a stored procedure from all the (think it's over 50places) where it is needed.

But I have one batch update to this table, that doesn’t require the trigger procedure; the trigger is very heavy so I would like to make an exception only in this update. Is it possible to write something into the UPDATE statement or do I have to disable and enable the trigger every time this update runs?
Similar Threads
Reputation Points: 18
Solved Threads: 0
Light Poster
NextCom is offline Offline
26 posts
since Dec 2008
Jul 1st, 2009
0

Re: Update table row without firing trigger?

Just to be clear, I’m thinking about something like this (except that I want to skip trigger instead of setting the update to only lock current row):
UPDATE <TABLENAME> WITH (ROWLOCK) SET <Column>='VALUE' WHERE ID=1

I have tried to put anything that comes into my mind after WITH, but still no luck.
Google haven't been at much help eiter.
Reputation Points: 18
Solved Threads: 0
Light Poster
NextCom is offline Offline
26 posts
since Dec 2008
Jul 1st, 2009
0

Re: Update table row without firing trigger?

Check out this thread:
http://stackoverflow.com/questions/4...for-one-insert

It offers a number of possible solutions but none are straight forward 'disable triggers for my individual session'.
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Jul 1st, 2009
0

Re: Update table row without firing trigger?

It's kind of same solution I’m implementing now.
I have added a column called "TUpdate" it's a bit column that i set to true in all the different update statements. This solution will not use much load on the server, because the first thing i do in the trigger is to check if the value in INSERTED is True, if it is then it continues to do the work in the trigger, and it updates this column to be false in the end. It will take some space in the database, because i have around 11,5 million rows, but it doesn’t mater that much.

But this is not the optimal solution, I have been looking for this many times. Many people or talking about using individual rights, where they check what user that fires the trigger, and i can see why it works for many people. But it's a loot of work to implement, and like i mentioned, I would like to use this many places.
Reputation Points: 18
Solved Threads: 0
Light Poster
NextCom is offline Offline
26 posts
since Dec 2008
Jul 2nd, 2009
1

Re: Update table row without firing trigger?

I'm verry close now.

For INSERT together with OPENROWSET you can use WITH (IGNORE TRIGGERS).

IGNORE_TRIGGERS
Is applicable only in an INSERT statement when the BULK option is used with OPENROWSET.

Specifies that any triggers defined on the table are ignored by the bulk-import operation. By default, INSERT applies triggers.

Use IGNORE_TRIGGERS only if your application does not depend on any triggers and maximizing performance is important.
Reputation Points: 18
Solved Threads: 0
Light Poster
NextCom is offline Offline
26 posts
since Dec 2008
Jul 14th, 2009
0

Re: Update table row without firing trigger?

hi friend,
to disable trigger :
DISABLE TRIGGER trigger_create
to enable trigger:
enable TRIGGER trigger_create

regards,
rathnakar
Reputation Points: 9
Solved Threads: 0
Newbie Poster
rathnakar is offline Offline
5 posts
since Nov 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MS SQL Forum Timeline: conversion of datetime when data is NULL
Next Thread in MS SQL Forum Timeline: Updating a table with variable column name, retrieved from another table ?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC