SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Triggers


Triggers

Author
Message
Latheesh NK
Latheesh NK
SSC Eights!
SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)

Group: General Forum Members
Points: 929 Visits: 2164
Hi,

I would like to know the difference between disabling and dropping a trigger. To me, Trigger is basically coupled with transaction hence write/reads entry from the log for the action. If that is the case, disabling a trigger would only stop the read operation however the write happens to the transaction log. For a big table with more transactions(updates/delete/insert), it would be great if we can drop the trigger instead of disabling so I can save the log file growth. So dropping a trigger would be the best one rather than disabling if it is not going to use in future.

Please correct me perhaps I am wrong on anything.
Rome1981
Rome1981
Valued Member
Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)

Group: General Forum Members
Points: 73 Visits: 106
If you aren't going to use the trigger anymore, drop it. If you do plan on using it in the future, I would disable it. Another alternative is to script the trigger out and recreate it/drop it with a script or job.
HowardW
HowardW
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2275 Visits: 9892
Whether you have triggers on a table or not has no bearing on whether transactions are written to the transaction log. All transactional operations are logged (in all recovery models) so you will not gain anything tangible by dropping vs disabling a trigger.

Also, triggers do not operate asyncronously, somehow mining the transaction log. They will be fired for each relevant DML statement as part of the same transaction.
Latheesh NK
Latheesh NK
SSC Eights!
SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)

Group: General Forum Members
Points: 929 Visits: 2164
Thanks for your comment!!!

Am really looking for an answer or confirmation as how the disabling of a trigger is working. As I mentioned, is this the way that it will log an entry in transaction log but it wont read from it or it wont write the entry at all if it is in disabled state?
HowardW
HowardW
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2275 Visits: 9892
sqlchanakya (2/28/2011)

Am really looking for an answer or confirmation as how the disabling of a trigger is working. As I mentioned, is this the way that it will log an entry in transaction log but it wont read from it or it wont write the entry at all if it is in disabled state?


No, triggers have absolutely no effect on whether the original transaction gets logged to the transaction log.
Latheesh NK
Latheesh NK
SSC Eights!
SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)

Group: General Forum Members
Points: 929 Visits: 2164
Could you plese check the below link and correct me where I interpreted wrongly...

http://sqlblogcasts.com/blogs/tonyrogerson/archive/2006/10/27/1248.aspx
HowardW
HowardW
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2275 Visits: 9892
Interesting...

That is written for 2000 (this is the 2008 forum) - what it's saying is that because the inserted and deleted tables need to include all columns, not just the ones affected by the update, some operations may end up with increased logging information.

I've never heard of this before and I can't see any official reference that supports it, but it does make some sense. I suspect that the huge changes between 2000 and 2008 will have changed this one way or another, however I'll see if I can do some digging (if one of the heavy weights hasn't answered it definitively by then)
Latheesh NK
Latheesh NK
SSC Eights!
SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)

Group: General Forum Members
Points: 929 Visits: 2164
Okei, In Paul Randal's blog, he mentioned for SQL 2005 or behind, they changed the way the trigger working. But I could not find how it works.

I would really appreciate if you could help me on the same as you said....I would also definitely look and share the same.
HowardW
HowardW
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2275 Visits: 9892
So, to clarify, which version of SQL Server are you using?
Latheesh NK
Latheesh NK
SSC Eights!
SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)SSC Eights! (929 reputation)

Group: General Forum Members
Points: 929 Visits: 2164
SQL Server 2008; however 80 compatibility ....
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search