back to top

SQL Script to Enable/Disable all triggers in a Database

One thing I find myself doing frequently is enabling/disabling triggers in an InforCRM database, especially with users who are not utilizing any of the newer ERP integration features found in current versions of InforCRM.

This script can be used to mass enable or disable all triggers in a database. Change which Declaration of the @action variable to switch between Enabling and Disabling triggers. Running this script will generate the statements to change the state of the triggers, while also running them. You can disable the Exec line to just get a list of Enable/Disable statements that you can run yourself.

/* Enable/Disable triggers script       */
/* Jason Buss - 2018-04-19              */
/* Enable line for action you want to perform (enable/disable) and run script in it's entirety */

DECLARE @action VARCHAR(8) = 'DISABLE';
--DECLARE @action varchar(8) = 'ENABLE';

DECLARE @catalog VARCHAR(10) = 'sysdba';  --or dbo
DECLARE @disabled BIT= 0;
DECLARE @stmt VARCHAR(255);
DECLARE @loop INT= 0;
DECLARE @cnt INT;
DECLARE @totalcnt INT;

IF(@action = 'ENABLE')
    SET @disabled = 1;

SELECT @cnt = COUNT(*)
FROM sys.triggers
WHERE is_disabled = @disabled;
SELECT @totalcnt = COUNT(*)
FROM sys.triggers;

IF @cnt <> 0
    BEGIN
        WHILE @loop <> @cnt
            BEGIN
                SELECT TOP 1 @stmt = @action+' TRIGGER '+TRIG.name+' ON '+@catalog+'.'+TAB.name+';'
                FROM [sys].[triggers] AS TRIG
                     INNER JOIN sys.tables AS TAB ON TRIG.parent_id = TAB.object_id
                WHERE trig.is_disabled = @disabled
                ORDER BY TAB.name,TRIG.name;

                SET @loop = @loop + 1;
                PRINT @stmt;
                EXEC (@stmt); --disable to print statements only
            END;
        PRINT LOWER(@action)+'d '+CONVERT(VARCHAR(5), @cnt)+' of '+CONVERT(VARCHAR(5), @totalcnt)+' triggers';
    END;
ELSE
    PRINT 'Out of '+CONVERT(VARCHAR(5), @totalcnt)+' triggers, no triggers to '+LOWER(@action);
Contact Customer FX for your CRM project
We let our expertise speak for itself - let us know how our all-star team can help on your CRM project
About the Author
Jason Buss
Jason Buss
Jason is a senior application developer with Customer FX.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Infor CRM Sync for Exchange: Action Required by August 31, 2026

Using Infor CRM Sync for Exchange with Microsoft 365? Your Exchange administrator must update tenant settings by August 31, 2026 to prevent sync disruption.

[Webinar] What’s Coming Next for Infor CRM SLX and Why v10 Matters

See what’s coming next for Infor CRM SLX, including new marketing workflows, automation improvements, and reasons to consider upgrading to v10.

Disable Caching in Infor CRM SLX Web Client

In the rare case caching is causing issues in the Infor CRM SLX web client, it is possible to disable specific types of caching by making edits using Application Architect, and then deploying.

Exploring AI Options for Infor CRM v10

I've started taking a closer look at the AI capabilities built into Infor CRM v10. Over the next several posts, I'll share what I learn. From the built-in features and supported AI providers to implementation considerations, costs, and practical use cases.

Infor CRM SLX 10.0: Delegate Ownership Changes for “Everyone” Records

Learn how the new EveryoneOwnerAssignment secured action in Infor CRM SLX 10.0 allows designated users to change ownership of Everyone-owned records without requiring Administrator access.

Related Articles

Infor CRM Sync for Exchange: Action Required by August 31, 2026

Using Infor CRM Sync for Exchange with Microsoft 365? Your Exchange administrator must update tenant settings by August 31, 2026 to prevent sync disruption.

[Webinar] What’s Coming Next for Infor CRM SLX and Why v10 Matters

See what’s coming next for Infor CRM SLX, including new marketing workflows, automation improvements, and reasons to consider upgrading to v10.

Disable Caching in Infor CRM SLX Web Client

In the rare case caching is causing issues in the Infor CRM SLX web client, it is possible to disable specific types of caching by making edits using Application Architect, and then deploying.

Exploring AI Options for Infor CRM v10

I've started taking a closer look at the AI capabilities built into Infor CRM v10. Over the next several posts, I'll share what I learn. From the built-in features and supported AI providers to implementation considerations, costs, and practical use cases.

Related Videos