|
Execute the following
script in Query Editor to create a trigger on the 2nd, 3rd, 4th and 5th columns (bitmask 30) of the Employee table.
USE Corporate;
CREATE TRIGGER trgUpdateEmployee
ON Employee
AFTER UPDATE AS
IF (COLUMNS_UPDATED() & 30) > 0
BEGIN
INSERT INTO CorpSecurityEmployeeHistory
(auditlogtype,
auditEmployeeDeptID,
auditEmployeeID,
auditEmployeeSalary,
auditEmployeeSSN)
SELECT 'PREVIOUSDATA',
DeptID,
EmployeeID,
Salary,
SSN
FROM DELETED
INSERT INTO CorpSecurityEmployeeHistory
(auditlogtype,
auditEmployeeDeptID,
auditEmployeeID,
auditEmployeeSalary,
auditEmployeeSSN)
SELECT 'NEWDATA',
DeptID,
EmployeeID,
Salary,
SSN
FROM INSERTED
END;
GO
|