建议采用英文字段。给你一个参考的trigger:-- 更新表pagecount时,更新表sitevisit
CREATE TRIGGER tr_pagecount_sitevisit ON [dbo].[pagecount]
FOR UPDATE
ASDECLARE @counts1 int, --旧的访问量
@counts2 int --新的访问量SET @counts1=(SELECT TOP 1 pcount FROM deleted)
SET @counts2=(SELECT TOP 1 pcount FROM inserted)
IF @counts2<>@counts1
UPDATE sitevisit SET counts=counts+(@counts2-@counts1) WHERE DATEDIFF(day,GETDATE(),visit_date)=0
CREATE TRIGGER tr_pagecount_sitevisit ON [dbo].[pagecount]
FOR UPDATE
ASDECLARE @counts1 int, --旧的访问量
@counts2 int --新的访问量SET @counts1=(SELECT TOP 1 pcount FROM deleted)
SET @counts2=(SELECT TOP 1 pcount FROM inserted)
IF @counts2<>@counts1
UPDATE sitevisit SET counts=counts+(@counts2-@counts1) WHERE DATEDIFF(day,GETDATE(),visit_date)=0
create trigger trig_a on a after (insert,update)
as
begin
insert b select id,typed,getdate(),status from inserted
end
as
begin
insert b select id,typed,getdate(),status from inserted
end