Brian's Blog

items I see across my tribes

Enable/disable Triggers: T-SQL and SSMS

October 28
by briancarter 28. October 2009 07:12

I have created triggers to track changed data in various fields of several tables. Such triggers work at table level and are attached with table.  Here is syntax to disable and enable trigger TRG_Job_Audit on Job table:

 

-- Disable the trigger
ALTER TABLE Job DISABLE TRIGGER [TRG_Job_Audit]
GO

-- Enable the trigger
ALTER TABLE Job ENABLE TRIGGER [TRG_Job_Audit]
GO

Same task may be performed very easily through SSMS. Suppose trigger TRG_Job_Audit is created on table Job. And we have to disable and enable it through SSMS

  • Open SSMS
  • Go to table on which trigger is defined
  • Open triggers folder under table

image

Right click on trigger and click on Disable.  Confirmation dialog will be shown and icon of trigger will be slightly changed showing the change in trigger status.

image

To enable the trigger through SSMS, again right click on disabled trigger and click Enable.

Categories: Development

Comments


 Questions or Feedback, my contact information is located on my About page.


The opinions, thoughts, and comments made in these blog posts are solely my own (unless otherwise stated). They do not reflect the opinions, thoughts or practices of my employer, my universities, my family, or anyone else. Also, I retain the right to change my mind about anything I publish here without having to go back and edit posts that occurred in the past. 

These are my opinions, or just as likely, someone else's opinions that I leveraged for my own.