我是创建触发器的新手。我正在尝试创建一个触发器,该触发器使用 tblAccounts.HotNote 更新 tblServiceOrders.GeneralSymptoms,其中 tblAccounts.Number = tblServiceOrders.AccountNumber 并且每当将新行添加到 tblServiceOrders 时。这是我到目前为止所得到的。
ALTER TRIGGER [dbo].[HOTNOTE_update] ON [dbo].[tblServiceOrders]
AFTER INSERT
AS
BEGIN
UPDATE tblServiceOrders tblAccounts.AccountNumber = tblServiceOrders.AccountNumber
SET GeneralSymptoms =
(
SELECT HotNote FROM tblAccounts, tblServiceOrders
WHERE tblAccounts.AccountNumber = tblServiceOrders.AccountNumber
)
FROM tblServiceOrders
WHERE tblServiceOrders.SOType = 'BE Maintenance' OR tblServiceOrders.SOType = 'DD Maintenance'
END