实现这样的效果A 表的 添加、更新、删除操作都在B表中做日志A表结构
A_ID = 自动增列(主键)
A_Info = 记录内容B表结构
OptionPKID = 操作的A表的对应主键ID
OptionType = 1添加操作 / 2更新操作 / 3删除操作
A_ID = 自动增列(主键)
A_Info = 记录内容B表结构
OptionPKID = 操作的A表的对应主键ID
OptionType = 1添加操作 / 2更新操作 / 3删除操作
解决方案 »
- 急!网站语言设置问题
- 能限制sa的权限吗?
- 一个存在'游标已存在'问题的存储,大家帮忙[给高分]
- 新人求助高人教教动态创建sql语句的问题
- 请教高手:两个无连接的数据库如何更新数据?(在线等待!急!)
- 这样做触发器是不是太笨?
- 这个sql语句该怎么写??
- 请关于SQL2000打包的问题??
- 加急!倾分相送!ADO.NET中怎么更新sql server中的image型字段?
- 谢谢,健入exp username/password@服务名 query='"where to_char(riqi,'YY-MM-DD')='01-04-01'"'仍提示列没有发现
- 一个简单的update怎么就是出错呢?请帮我看看谢谢
- 读取周一到周日的存储过程,怎么写??
create table a(A_ID int identity(1,1) primary key,A_Info varchar(50))
gocreate table b(OptionPKID int,OptionType varchar(10),[date] datetime)
gocreate trigger cfq on a
for insert,update,delete
asif @@rowcount=0 returndeclare @count_del int
declare @count_ins int
set @count_del=0
set @count_ins=0select @count_del=count(*) from deleted
select @count_ins=count(*) from insertedif (@count_ins>0 and @count_del=0)
begin
if @@error=0
insert into b select A_ID,'插入操作',getdate() from inserted
endif (@count_ins>0 and @count_del>0)
begin
if @@error=0
insert into b select A_ID,'更新操作',getdate() from inserted
endif (@count_ins=0 and @count_del>0)
begin
if @@error=0
insert into b select A_ID,'删除操作',getdate() from deleted
end
go
insert into a select 'song'
insert into a select 'rr'
insert into a select 'sxx'
insert into a select 'uu'
select * from a
select * from b
update a set A_info='111' where A_ID=1
select * from a
select * from b
delete a where A_info='111'
delete a where A_info='rr'
select * from a
select * from b
drop trigger cfq
drop table a
drop table b