Hi! I hope someone can help me with the following: I need to know if it is possible to implement a trigger that monitors the value of an specific field, and when it changes the value, it should update the value of another field in another table.
A:
Please see the below example
IF EXISTS (SELECT name FROM sys.objects
WHERE name = 'reminder' AND type = 'TR')
DROP TRIGGER Person.reminder;
GO
CREATE TRIGGER reminder
ON Person.Address
AFTER UPDATE
AS
IF ( UPDATE (StateProvinceID) OR UPDATE (PostalCode) )
BEGIN
RAISERROR (50009, 16, 10)
END;
GO
-- Test the trigger.
UPDATE Person.Address
SET PostalCode = 99999
WHERE PostalCode = '12345';
GO