当前位置: 代码迷 >> Sql Server >> 求一触发器!解决方案
  详细解决方案

求一触发器!解决方案

热度:28   发布时间:2016-04-27 21:15:13.0
求一触发器!
有两表,table1   和   table2,想更新table1中的一些记录,在更新之前将原记录保存在table2中,多谢各位!

------解决方案--------------------
呵呵
这样就可以了

create table t1 ( num int)

create table t2 (num int)

insert t1 select 1
union select 2
union select 3
union select 4
union select 5
go
create trigger t on t1 for update
as
insert t2 select * from deleted
go

update t1 set num=11 where num=1

select * from t2
  相关解决方案