能做到,但是恢复sql 语句比较麻烦,也没有必要,一般应该是保存改前记录和改后记录。create trigger tr_test_update
on test
for update
as
insert testlogs
select *,SUSER_SNAME(),getdate(),'deleted' as type
from deleted
union all
select *,SUSER_SNAME(),getdate(),'inserted' as type
from inserted
go
on test
for update
as
insert testlogs
select *,SUSER_SNAME(),getdate(),'deleted' as type
from deleted
union all
select *,SUSER_SNAME(),getdate(),'inserted' as type
from inserted
go
解决方案 »
- 请问,这几张表如何建合理
- 多久不来, 散个分, 顺便问个问题..
- (20分)求一个3表插入问题!
- 如何动态的插入数据select * into @表名(动态生成)from
- 100分!两个服务器上的数据库定时同步问题,急!!!!!!!!!!!!!
- 求一个sql
- 如何将下面的oracle的sql 语句转换成sql server的sql 语句
- 誰能用SQL SERVER 2000幫忙給一個16進制轉成10進制的函數
- 有没有这样的sql语句:转移表中的数据到另外一个表 (目的表已经存在)
- SQL SERVER 2000 ,如何提供互联网查询服务,(最好有现成的样例的,无内容)
- 请问如果一台机器上有多个SQL SERVER实例,如何连接到非默认的实例上?
- 100高分求教,如何删除表中的某个字段!
sasacat(傻傻猫) :存储过程应该怎样写?
update test
set a=a
where id=1
这样的语句,数据没有变化,就测不出来。
在业务流程上他不会被update成别的值,但是我们在使用这个的table时,发现有些纪录的这个栏位被update成别的值,所以我想把写触发器来查找他为什么会被改掉!大家帮我想个别的方法也可以!
update 表 set 列 = 列 where 列 = 列
那通过分析deleted和inserted是什么也分析不出来的。
因为好多测不出来,比如set a=a+1,where 部分也是测不出来。
我觉得还是记录改前和改后的整条记录比较现实。