首先創建一個存儲過程來更新您的[ApprovedAmount]
列
create procedure SP_UpdateRequestedAmount
(@EmpID int,
@AmountApproved varchar (50),
@RequestPriority varchar (50))
as
begin
Update Requests
set ApprovedAmount = @AmountApproved,
Request_Priority = @RequestPriority
where
Emp_ID = @EmpID
end
然後用TRIGER更新其他表時曾經[AmountApproved]列被更新
CREATE TRIGGER tr_ApprovedAmount_UPDATE
ON Requests
AFTER UPDATE
AS
--Make sure Priority was changed
IF NOT UPDATE(ApprovedAmount)
RETURN
--Determine if Priority was changed to high
-- PUT your queries for Updatating other table
declare @Balance_LastUpdated date
declare @ApprovedDate date
UPDATE Balance Tracker
SET Balance Tracker.Balance_BalanceAmount = Balance Tracker.Balance_BalanceAmount + PTS_Requests.Request_IsApproved,
Balance_LastUpdated = @Balance_LastUpdated,
Balance_LastApproval = @ApprovedDate
FROM
Balance Tracker
INNER JOIN
Requests ON Balance Tracker.Emp_ID = Requests.Emp_ID
希望這有助於.........