Search code examples
sql-servertriggers

Disable Enable Trigger SQL server for a table


I want to create one proc like below but it has error on syntax. Could anyone pointing out the problem?

Create PROCEDURE [dbo].[my_proc] AS

BEGIN

DISABLE TRIGGER dbo.tr_name ON dbo.table_name

-- some update statement

ENABLE TRIGGER dbo.tr_name  ON dbo.table_name

END

** Error Message : Incorrect syntax near 'ENABLE'.

Solution

  • use the following commands instead:

    ALTER TABLE table_name DISABLE TRIGGER tr_name
    
    ALTER TABLE table_name ENABLE TRIGGER tr_name