create trigger trg1
on [table]
for update
as
begin
--取的更新后的记录
select * from inserted
--判断是否更新
if update(name)
select name from inserted
......
end
go
on [table]
for update
as
begin
--取的更新后的记录
select * from inserted
--判断是否更新
if update(name)
select name from inserted
......
end
go
CREATE TRIGGER t_insert
ON 你自己的表
FOR INSERT
AS
set xact_abort on
begin tran
insert Test_2 select * from Inserted
commit tran
go
samfeng_2003(风云) 兄台,我也想按你的那一种方式。做但是DataBase中那么多的表。我不要在那么多的表中*2。其实我只是想当表插入、更新、删除,用触发器得到数据,拼成原来的动作,放到另一个表中去.那一个表只有两个字段.
如:
ID 数据
1 insert table1 values('1','2')
2 Update table2 set name='1' where iid=1
3 delete table5 where iid='4'
-------------------
2 'xxx' 'Update'
4 'yyy' 'insert'
6 'ttt' 'delete'
-------------------
2 'xxx' 'Update'
4 'yyy' 'insert'
6 'ttt' 'delete'