Inserting an explicit null value into a column or using the DEFAULT keyword to assign a value to a column activates the trigger as expected. Similarly, when no value is specified in the INSERT statement for a column, the trigger is still activated when:
CREATE TABLE junk
(a int NULL, b int NOT NULL DEFAULT 99)
GO
CREATE TRIGGER junktrig
ON junk
FOR INSERT, UPDATE
AS
IF UPDATE(a) AND UPDATE(b)
PRINT 'FIRING'
GO
INSERT junk (a, b) |
/*IF UPDATE is true for both columns, */ |
UPDATE junk |
/*IF UPDATE is true for both columns, */ |
INSERT junk |
/*Explicit NULL. */ |
UPDATE junk |
/*IF UPDATE is true for both columns, */ |
INSERT junk (b) |
/*No default on column a. */ |
UPDATE junk |
/*IF UPDATE is not true for both columns, */ |
INSERT junk (a) |
/*Default on column b. */ |
UPDATE junk |
/*IF UPDATE is not true for both columns, */ |
INSERT junk (a, b) |
/*DEFAULT explicitly inserted. */ |
UPDATE junk |
/*IF UPDATE is true for both columns, */ |
Null Values | DEFAULT Definitions |