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 10: Phone Number “Starts With” Search Not Working with Formatted Numbers

Infor CRM 10's Starts With search may fail to find phone numbers stored with formatting characters. Learn why this happens, how to identify affected records, and how to resolve the issue.

Increase Attachment Size Allowed in the Infor CRM SLX Web Client

It is possible to increase Infor CRM SLX's limit on the size of a file that can be uploaded by editing values in web.config file.

A Closer Look at the AI Features in Infor CRM v10

Infor CRM v10 includes several built-in Generative AI features that go beyond a simple chatbot. Here's a closer look at AI Summary, AI Assistant, AI Newsfeed, and AI-assisted email drafting.

[Webinar] Infor CRM SLX Admin Essentials: Xbar for Web and Email Marketing

On Tuesday, September 15, 2026, Infor is hosting an...

Infor CRM Mobile 4.4 Now Available: What’s New

Infor CRM Mobile 4.4 is now available for single-tenant cloud and on-premises customers. Explore business card capture, dashboards, workflows, and more.

Related Articles

Infor CRM 10: Phone Number “Starts With” Search Not Working with Formatted Numbers

Infor CRM 10's Starts With search may fail to find phone numbers stored with formatting characters. Learn why this happens, how to identify affected records, and how to resolve the issue.

Increase Attachment Size Allowed in the Infor CRM SLX Web Client

It is possible to increase Infor CRM SLX's limit on the size of a file that can be uploaded by editing values in web.config file.

A Closer Look at the AI Features in Infor CRM v10

Infor CRM v10 includes several built-in Generative AI features that go beyond a simple chatbot. Here's a closer look at AI Summary, AI Assistant, AI Newsfeed, and AI-assisted email drafting.

[Webinar] Infor CRM SLX Admin Essentials: Xbar for Web and Email Marketing

On Tuesday, September 15, 2026, Infor is hosting an administrator-focused webinar covering two areas that can help organizations...

Related Videos