问一个简单的触发器问题
触发器如下:
create trigger trgaa
on Emp1
for update
as
if(update(Age))
begin
update Emp1 set GZ=GZ+1 where Code=????
end
当我更新某一行年龄时,要将这一行的GZ+1。那我在触发器里怎么写where条件啊??
Code为主键。
------解决方案--------------------create trigger trgaa
on Emp1
for update
as
if(update(Age))
begin
update Emp1 from deleted d set GZ=GZ+1 where Code=d.code
end
------解决方案-------------------- update Emp1 set GZ=GZ+1 where Code in (select code from deleted)