I have the attached trigger that runs if the tbl_repair_visit.TENANTSATISFACTION = 'Poor'
on an update.
The issue i have if we change the engineers name the Engineer column gets updated and the trigger runs again if TENANTSATISFACTION = 'Poor'
How can i set this up to only run if the TENANTSATISFACTION = 'Poor'
column is updated and ignor updates on all other columns
ALTER TRIGGER [dbo].[tr_CustomerSatisfactionAlertRepair]
ON [dbo].[tbl_repair_visit]
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;
INSERT alertmessagedata (TypeID, Contract, Address, ORDERID,
ENGINEERS, Sent, DateAdded)
SELECT '5', tbl_property.contract, tbl_property.fulladdress,
tbl_repair_visit.orderid, tbl_repair_visit.engineer,
0, GETDATE()
FROM TBL_REPAIR_VISIT
INNER JOIN
INSERTED X ON TBL_REPAIR_VISIT.VISITID = X.VISITID
INNER JOIN
TBL_PROPERTY ON TBL_REPAIR_VISIT.PROPREF = TBL_PROPERTY.PROPREF
WHERE tbl_repair_visit.TENANTSATISFACTION = 'Poor'
END