從 MSSQL 2005 版本開始,想停用或啟用 Trigger 就簡單多了,語法如下:

停用 Trigger ( 觸發程序 )

語法:

1
2
DISABLE TRIGGER { [ schema_name . ] trigger_name [ ,...n ] | ALL }
ON { object_name | DATABASE | ALL SERVER } [ ; ]

實作:

1
DISABLE TRIGGER dbo.trigName ON dbo.tableName

啟用 Trigger ( 觸發程序 )

語法:

1
2
ENABLE TRIGGER { [ schema_name . ] trigger_name [ ,...n ] | ALL }
ON { object_name | DATABASE | ALL SERVER } [ ; ]

實作:

1
ENABLE TRIGGER dbo.trigName ON dbo.tableName