请大家帮我看看这个触发器

无锡阔微信息科技 2010-07-01 09:46:33
create trigger t_Icstocktrigger on icstockbillentry
for insert
as
begin
declare @SanFitemID int
set @SanFitemID=cast((select isnull(FEntrySelfB0169,0) from inserted) as int)
if @SanFitemID=20273
begin
update icstockbillentry u1,inserted i
set u1.FConsignPrice=0,u1.FEntrySelfB0159=0,u1.FNote='保用'
where u1.finterID=i.finterID and u1.fentryID=i.fentryID
end
end


错误:
消息 102,级别 15,状态 1,过程 t_Icstocktrigger,第 9 行
'u1' 附近有语法错误。
...全文
95 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
SQL_Hhy 2010-07-01
  • 打赏
  • 举报
回复
update u1
set u1.FConsignPrice=0,u1.FEntrySelfB0159=0,u1.FNote='保用'
from icstockbillentry u1,inserted i
where u1.finterID=i.finterID and u1.fentryID=i.fentryID
end
chuifengde 2010-07-01
  • 打赏
  • 举报
回复
CREATE TRIGGER t_Icstocktrigger
ON icstockbillentry
FOR INSERT
AS
BEGIN
UPDATE u1
SET u1.FConsignPrice = 0,
u1.FEntrySelfB0159 = 0,
u1.FNote = '保用'
FROM icstockbillentry u1,INSERTED i
WHERE u1.finterID = i.finterID
AND u1.fentryID = i.fentryID
AND ISNULL(i.FEntrySelfB0169, 0)=20273
END
chuifengde 2010-07-01
  • 打赏
  • 举报
回复
你的触发器这样写有隐患,如果一次插入多行就麻烦了
dawugui 2010-07-01
  • 打赏
  • 举报
回复
update icstockbillentry u1 
set FConsignPrice = 0 , FEntrySelfB0159 = 0 , FNote = '保用'
from icstockbillentry u1 , inserted i
where u1.finterID = i.finterID and u1.fentryID = i.fentryID
  • 打赏
  • 举报
回复
我马上结贴
  • 打赏
  • 举报
回复
不行啊又报错了
消息 4104,级别 16,状态 1,过程 t_Icstocktrigger,第 9 行
无法绑定由多个部分组成的标识符 "u1.FConsignPrice"。
wujinyuan 2010-07-01
  • 打赏
  • 举报
回复
update u1
set u1.FConsignPrice=0,u1.FEntrySelfB0159=0,u1.FNote='保用'
from icstockbillentry u1,inserted i
where u1.finterID=i.finterID and u1.fentryID=i.fentryID
中国风 2010-07-01
  • 打赏
  • 举报
回复
update icstockbillentry u1,inserted i
set u1.FConsignPrice=0,u1.FEntrySelfB0159=0,u1.FNote='保用'
where u1.finterID=i.finterID and u1.fentryID=i.fentryID

改為
update u1
set u1.FConsignPrice=0,u1.FEntrySelfB0159=0,u1.FNote='保用'
from icstockbillentry u1,inserted i
where u1.finterID=i.finterID and u1.fentryID=i.fentryID
永生天地 2010-07-01
  • 打赏
  • 举报
回复
update u1
set u1.FConsignPrice=0,u1.FEntrySelfB0159=0,u1.FNote='保用'
from icstockbillentry u1,inserted i
where u1.finterID=i.finterID and u1.fentryID=i.fentryID
end
jwdream2008 2010-07-01
  • 打赏
  • 举报
回复
create trigger t_Icstocktrigger on icstockbillentry
for insert
as
begin
declare @SanFitemID int
set @SanFitemID=cast((select isnull(FEntrySelfB0169,0) from inserted) as int)
if @SanFitemID=20273
begin
update icstockbillentry
set u1.FConsignPrice=0,u1.FEntrySelfB0159=0,u1.FNote='保用'
from icstockbillentry u1,inserted i
where u1.finterID=i.finterID and u1.fentryID=i.fentryID
end
end

34,588

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧