SQLServer 中更新一个表中的多条记录时,是否能够触发每一记录的触发器?
我的触发器如下:ALTERTRIGGER[TrGetDate]ONdbo.TblWOItemFORINSERT,UPDATEASif(update(ManHour))be...
我的触发器如下:
ALTER TRIGGER [TrGetDate] ON dbo.TblWOItem
FOR INSERT, UPDATE
AS
if (update(ManHour))
begin
declare @id int
declare @TC varchar(50)
declare @Mh float
declare @BMH float
select @id = ITEMID from inserted
select @tc = TaskcardId from inserted
select @MH = isnull(ManHour,0) from inserted
Set @BMH= (Select BoeingMH from dbo.tbl_taskInf where taskcard=@tc)
if (@BMH=0)
begin
Set @BMH=isnull(dbo.fGetBoeingMH(@tc),0)* 60
End
if (@MH>0)
begin
Set @Mh=dbo.fGetTaskMh(@tc)
update tblWOItem set UPDATEDATE=getdate(),RecommendMHour=@MH,UpdateBy=HOST_NAME() where ITEMID=@id
end
END 展开
ALTER TRIGGER [TrGetDate] ON dbo.TblWOItem
FOR INSERT, UPDATE
AS
if (update(ManHour))
begin
declare @id int
declare @TC varchar(50)
declare @Mh float
declare @BMH float
select @id = ITEMID from inserted
select @tc = TaskcardId from inserted
select @MH = isnull(ManHour,0) from inserted
Set @BMH= (Select BoeingMH from dbo.tbl_taskInf where taskcard=@tc)
if (@BMH=0)
begin
Set @BMH=isnull(dbo.fGetBoeingMH(@tc),0)* 60
End
if (@MH>0)
begin
Set @Mh=dbo.fGetTaskMh(@tc)
update tblWOItem set UPDATEDATE=getdate(),RecommendMHour=@MH,UpdateBy=HOST_NAME() where ITEMID=@id
end
END 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询