数据库记录修改

jannock 2006-04-24 06:54:06
请问一下
我有一个表A (ID XM )等等
我想 的到这个表的 修改 记录
什么时候 什么人 修改了什么内容??
改如何设计呢??
...全文
187 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhang_yzy 2006-04-25
  • 打赏
  • 举报
回复
1\在A表中增加修改人或建立人字段和时间字段,
2\另建立一个表B用于保存变更记录,
3\在A表上建立INSERT\UPDATE\DELETE触发器,在变更时,将信息保存到B中
jannock 2006-04-25
  • 打赏
  • 举报
回复
能说的具体吗???
Night26 2006-04-24
  • 打赏
  • 举报
回复
前台控制不现实,假如调用存储过程怎么办?
Night26 2006-04-24
  • 打赏
  • 举报
回复
邹建老大有方法,我以前看过他写的关于这方面的文章。最近我想参考发现找不到了。
jixiaojie 2006-04-24
  • 打赏
  • 举报
回复
up
panjinfu80 2006-04-24
  • 打赏
  • 举报
回复
在前台控制也可以。
xeqtr1982 2006-04-24
  • 打赏
  • 举报
回复
恩,同意楼上.操作员很难得到
szztao 2006-04-24
  • 打赏
  • 举报
回复
最好自己在程序中控制,用Sql本身的功能无法得到具体的操作员信息,只能得到连接用户信息
xeqtr1982 2006-04-24
  • 打赏
  • 举报
回复
create table tb(id int,name varchar(10))
go

create table tt(id int,name varchar(10),lb varchar(10),[date] datetime)
go

create trigger cfq on tb
for insert,delete,update
as

if @@rowcount=0 return

declare @count_ins int
declare @count_del int
select @count_ins=count(1) from inserted
select @count_del=count(1) from deleted

if(@count_ins>0 and @count_del=0)
begin
insert into tt select id,name,'insert',getdate() from inserted
end

if(@count_ins>0 and @count_del>0)
begin
insert into tt select id,name,'update',getdate() from inserted
end

if(@count_ins=0 and @count_del>0)
begin
insert into tt select id,name,'delete',getdate() from deleted
end
go

insert into tb select 1,'song'
insert into tb select 2,'asong'
go

delete tb where id=1
go

update tb set name='aa' where id=2
go

select * from tb
select * from tt

drop trigger cfq
drop table tb,tt
xeqtr1982 2006-04-24
  • 打赏
  • 举报
回复
事件探察器也可以
xeqtr1982 2006-04-24
  • 打赏
  • 举报
回复
可以用触发器

34,575

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧