T-SQL » Triggers » Modifying a Trigger

Syntax:
ALTER TRIGGER trigger_name
ON table
[ WITH ENCRYPTION ]
{
    {
       FOR { [ DELETE ] [ , ] [ UPDATE ] [ , ] [ INSERT ] }
          [ NOT FOR REPLICATION ]
          AS
             sql_statement [ ...n ]
    }
    |
    {
       FOR { [ INSERT ] [ , ] [ UPDATE ] }
          [ NOT FOR REPLICATION ]
          AS
          {
             IF UPDATE ( column )
  &nb

A trigger can be modified by either, deleting the trigger and recreating a new trigger or by altering the existing trigger. The parameters from the ALTER TRIGGER statement are similar to those from the CREATE TRIGGER statement.

Examples

Code:
ALTER TRIGGER trigAddStudents
ON Students
FOR INSERT
AS
PRINT 'THE TRIGGER IS CHANGED.';
Output:
The command(s) completed successfully.
Explanation:

The above example modifies the trigger created earlier by changing the print that is to be displayed when the trigger is 'fired'.

Language(s): MS SQL Server
Code:
INSERT INTO Students VALUES (7,'Tom George', 1, 45452, 2);
Output:
THE TRIGGER IS CHANGED.
(1 row(s) affected)
Explanation:

When the INSERT statement is executed, the modified trigger is 'fired.'

Language(s): MS SQL Server