Find SQL Server Trigger(s) associated with a table and how to enable/disable them


If you want to know whether there is any trigger associated with a specific table in your database, you can run the following query.

SELECT * FROM sys.triggers WHERE parent_id = OBJECT_ID(N‘yourTableName’)

Sometime you may need to turn the trigger on and off test your queries. You can use query snipt below to do that:

–Turn off your trigger

ALTER

table yourTableName

DISABLE

trigger myTrigger

–SELECT

* FROM sys.triggers WHERE parent_id =  OBJECT_ID(N‘yourTableName’) 

–turn on your trigger

ALTER

tableyourTableName

ENABLE

trigger myTrigger

–SELECT

* FROM sys.triggers WHERE parent_id =  OBJECT_ID(N‘yourTableName’)

There is a column named as is_disabled and you can find the value change in that column when you run the first query at the beginning.

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s