create trigger triTest
on A
for update
as
begin
insert b
select getdate(),id,'修改' from inserted a
where not exists(select * from b b where a.id=b.id)
and a.id>10
end
create trigger triTest
on A
for update
as
begin
insert b
values(getdate(),
select id from inserted a
where not exists(select * from b b where a.id=b.id)
and a.id>10,'修改')
end
我现在改成了这样,但是结果不对,当a.id<=10的update时,仍然会执行插入操作,只是b表中的id为空而已
create trigger triTest
on A
for update
as
begin
insert b
select xxx,xxx from inserted a
where not exists(select * from b b where a.id=b.id)
and a.id>10
end
create trigger triTest
on A
for update
as
begin
if (updated.a>10) and updated.ID not in(select ID from b)
begin
insert b values(getdate(),updated.ID,a)
end
end
这是我查了触发器基本语法后,写的一个很挫的sql语句。。。显然用不了。。。希望高人不吝指点。。。