Tuesday, January 8, 2013

Trigger Happy - New SQL 2012 Functions

SQL 2012 introduces new functions to test for changes inside a trigger

UPDATE() tests for UPDATE or INSERT attempts on one column.

COLUMNS_UPDATED() tests for UPDATE or INSERT actions performed on multiple columns.

CREATE TRIGGER trgColumnChange
ON TABLE FOR UPDATE
AS
IF UPDATE(columnname)
BEGIN
-- Do Audit stuff here
END

COLUMNS_UPDATED (Transact-SQL)

No comments: