create proc proc_editType
ascreate trigger tr_update
on TargetType
for update
as
begin
if update(type)
begin
update t2
set type = i.type
from TargetItem t2
right join inserted i on t2.code = i.code
update t3
set type = i.type
from Item t3
right join inserted i on t3.Icode = i.code
end
end
go错误提示:
Server: Msg 156, Level 15, State 1, Procedure proc_editType, Line 4
Incorrect syntax near the keyword 'trigger'.
Server: Msg 140, Level 15, State 1, Procedure proc_editType, Line 9
Can only use IF UPDATE within a CREATE TRIGGER statement.正确的该怎么放呀?注:触发器没问题!
ascreate trigger tr_update
on TargetType
for update
as
begin
if update(type)
begin
update t2
set type = i.type
from TargetItem t2
right join inserted i on t2.code = i.code
update t3
set type = i.type
from Item t3
right join inserted i on t3.Icode = i.code
end
end
go错误提示:
Server: Msg 156, Level 15, State 1, Procedure proc_editType, Line 4
Incorrect syntax near the keyword 'trigger'.
Server: Msg 140, Level 15, State 1, Procedure proc_editType, Line 9
Can only use IF UPDATE within a CREATE TRIGGER statement.正确的该怎么放呀?注:触发器没问题!
關鍵字 'trigger' 附近的語法不正確。
伺服器: 訊息 140,層級 15,狀態 1,程序 proc_editType,行 7
只能在 CREATE TRIGGER 陳述式中使用 IF UPDATE。
as
declare @SQL varchar(4000)
set @SQL ='
create trigger tr_update
on TargetType
for update
as
begin
if update(type)
begin
update t2
set type = i.type
from TargetItem t2
right join inserted i on t2.code = i.code
update t3
set type = i.type
from Item t3
right join inserted i on t3.Icode = i.code
end
end '
execute(@SQL);
go