Programming in MS SQL Server 2012

DISABLE Trigger



DISABLE TRIGGER statement is used to disable existed trigger. Disabled trigger does not drop from user-defined database. Yet, disabled trigger does not fire when execute any Transact-SQL statements based on pre-defined business rules. Disabled trigger can be re-enabled by using ENABLE TRIGGER.

The following example describes to disable existed DML trigger object.

-- Example 136 --

 

USE EBusiness

GO

 

IF OBJECT_ID ('dbo.DMLProductTableTrigger','TR') IS NOT NULL

    DISABLE TRIGGER dbo.DMLProductTableTrigger ON dbo.Product;

GO


Query Output Screen



The following example describes to disable existed DDL trigger object.

-- Example 137 --

 

USE EBusiness

GO

 

IF EXISTS (SELECT * FROM sys.triggers

    WHERE parent_class = 0 AND name = 'DDLControlTrigger')

    DISABLE TRIGGER DDLControlTrigger ON DATABASE;

GO


Query Output Screen



* * * * *


Email Your Comment To AUTHOR