这个触发器错哪里了,帮忙给看一下
drop trigger T_updte_ammecopy
--drop trigger T_delete_ammeter
--drop trigger T_update_ammetermod
--drop trigger T_update_user
--drop trigger T_update_trans
create trigger T_updte_ammecopy
on copyinfo
for update
as
begin
if update(copydata)
begin
begin tran trans1
insert into copymodiinfo ( userid ,
ammeterid ,
copydate ,
timerflag ,
ammeteruseful ,
nextcopydate ,
nextcopydata ,
copydata ,
ammetermod ,
realdata ,
adddata ,
addreason ,
operid ,
usercomparid ,
booknum ,
charcomid ,
modicopydata ,
modioperid ,
modirealdata
)
select a.userid ,
a.ammeterid ,
a.copydate ,
a.timerflag ,
a.ammeteruseful ,
a.nextcopydate ,
a.nextcopydata ,
b.copydata ,
a.ammetermod ,
b.realdata ,
a.adddata ,
a.addreason ,
b.operid ,
a.usercomparid ,
a.booknum ,
a.charcomid ,
a.copydata ,
a.operid ,
a.realdata
from inserted a
left join deleted b
on (a.userid = b.userid) and (a.ammeterid = b.ammeterid)
and (a.copydate = b.copydate) and (a.timerflag = b.timerflag)
commit tran trans1
end
end
go
服务器: 消息 111,级别 15,状态 1,行 7
'CREATE TRIGGER ' 必须是批查询中的第一条语句。
服务器: 消息 140,级别 15,状态 1,行 12
只能在 CREATE TRIGGER 语句内部使用 IF UPDATE。
------解决方案--------------------1.drop trigger T_updte_ammecopy 后加一个 go
2.少了一个end