我在sql server 2008中創建了一個下面的觸發器,只要在我的W_Data表列PLName中發生更改,它就不會觸發。我在A_Ticket中看到相同的列數。任何人都可以幫我嗎?SQL Server 2008更新觸發器在指定列中發生任何更改時不起作用
CREATE TRIGGER dbo.tr_W_Data
ON dbo.W_Data
after update
AS
declare @date datetime
select @date = max(Start_Date) from dbo.W_Schedule
set NOCOUNT ON;
if update(PLName)
begin
update t set
I_S1_O = (select count(*) from W_Data w where [Priority] = 'S1' and [Type] <> 'R' and [A_Group] <> '1' and [C_Date]< @date and w.[Product_Name] = t.[Product_Name]),
I_S1_R = (select count(*) from W_Data w where [Priority] = 'S1' and [Type] <> 'R' and [A_Group] <> '1' and [C_Date]>= @date and w.[Product_Name] = t.[Product_Name]),
I_S1_Re = (select count(*) from W_Data w where [Priority] = 'S1' and [Type] <> 'R' and [R_Group] <> '1' and [R_Group] is not NULL and w.[Product_Name] = t.[Product_Name]),
.....
from ATicket t
end
go
這是因爲你的條件。如果update(plname)是什麼意思? –
@AmirrezaKeshavarz任何更新發生在W_Data中的PLName列中,這應該執行更新查詢 – Sathish
您沒有在觸發器中引用任何僞表「插入」或「更新」 - 因此您並不真正查看那些行已更新...... –