写了触发器不起作用,谁能帮我看一下问题出在哪
create trigger tigger20130828 on seoutstockentry
for insert
as
declare @FCustID int,
@FItemID int
select @FCustID=fcustid,@FItemID=fitemid from inserted t1,seoutstock t2 where t1.finterid=t2.finterid
if EXISTS
(select TOP 1 fcustid,fitemid
FAuxTaxPrice from ICSaleEntry u1
left join ICSale v1 on u1.FInterID=v1.FInterID
where
fcustid=@FCustID and fitemid=@FItemID
and FAuxTaxPrice>0 and FStatus=1 and FCancellation=0
order by v1.FDate desc,u1.FInterID desc,u1.FEntryID desc
)
update w2 set w2.fauxprice=w4.fauxprice from seoutstock w1,seoutstockentry w2 ,inserted w3,
(
select TOP 1 fcustid,fitemid,fauxprice
from ICSaleEntry u1
left join ICSale v1 on u1.FInterID=v1.FInterID
where
fcustid=@FCustID and fitemid=@FItemID
and FAuxTaxPrice>0 and FStatus=1 and FCancellation=0
order by v1.FDate desc,u1.FInterID desc,u1.FEntryID desc
)w4
where
w1.finterid=w2.finterid and
w2.finterid=w3.finterid and
w2.fentryid=w3.fentryid and
w1.fcustid=w4.fcustid and
w2.fitemid=w4.fitemid
------解决方案--------------------CREATE TRIGGER tigger20130828 ON seoutstockentry
FOR INSERT
AS
DECLARE @FCustID INT ,
@FItemID INT
SELECT @FCustID = fcustid ,
@FItemID = fitemid
FROM inserted t1 ,
seoutstock t2
WHERE t1.finterid = t2.finterid