create table 表 (a int)
go
insert 表 values (1)
go
CREATE TRIGGER 名 ON 表
FOR UPDATE
AS
select a 更新前被删除的数据 from deleted
select a 更新后被插入的数据 from inserted
go
------------测试:
update 表 set a=3
go
insert 表 values (1)
go
CREATE TRIGGER 名 ON 表
FOR UPDATE
AS
select a 更新前被删除的数据 from deleted
select a 更新后被插入的数据 from inserted
go
------------测试:
update 表 set a=3
update a set a.modifydate = getdate()
from 表 a
join inserted b on a.主键 = b.主键
for update
as
if update(score)
update 表 set modifydate=getdate()
go
for update
as
if update(score)
update 表 set modifydate=getdate()
from 表 a join inserted b on a.主键=b.主键
go
for update
as
if update(score)
update 表 set modifydate=getdate()
go
create trigger t_update on 表
instead of update
as
if update(score)
update 表 set modifydate=getdate()
from 表 a join inserted b on a.id=b.id
go
create trigger t_update on 表
instead of update
as
if update(score)
update 表 set modifydate=getdate()
from 表 a join inserted b on a.id=b.id
go
--b表就是inserted呀,是触发器自动新建的一个表,用来存放要插入的数据记录的!