create trigger tri_test on table for update as if update table.a1 or table.a2 or table.a3 begin SET NOCOUNT ON update table set 更新日期=getdate() end
Create Trigger T_update on Table for update as begin update Table set datetime=getdate() from Table a,Inserted b where a.id=b.id end go
create trigger ddd on table for update asupdate table set 更新日期= getdate() where 主键 in (select 主键 from inserted )
create table t([id] int,[name] varchar(10),更新日期 datetime) goinsert into t select 1,'aaa',NULL insert into t select 2,'ttt',NULL insert into t select 3,'yyy',NULL gocreate trigger cfq on t for update asif @@rowcount=0 returnif update([name]) update t set 更新日期=getdate() from inserted a,t b where a.[id]=b.[id] goupdate t set [name]='aaaddd' where [id]=1 select * from t drop trigger cfq drop table t
if update table.a1 or table.a2 or table.a3 begin
SET NOCOUNT ON
update table set 更新日期=getdate()
end
for update
as
begin
update Table set datetime=getdate() from Table a,Inserted b where a.id=b.id
end
go
on table
for update
asupdate table set 更新日期= getdate()
where 主键 in (select 主键 from inserted )
goinsert into t select 1,'aaa',NULL
insert into t select 2,'ttt',NULL
insert into t select 3,'yyy',NULL
gocreate trigger cfq on t
for update
asif @@rowcount=0 returnif update([name])
update t set 更新日期=getdate() from inserted a,t b where a.[id]=b.[id]
goupdate t set [name]='aaaddd' where [id]=1
select * from t
drop trigger cfq
drop table t