转载邹兄的:-------------------------参考,记录操作的示例----------------------------创建记录的日志表
create table t_log(
id int identity(1,1) primary key,
工作站名 nchar(30) not null default host_name(),
操作员 sysname DEFAULT SUSER_SNAME(),
操作时间 datetime default getdate(),
事件类型 nvarchar(30),
参数 int,
执行的语句 nvarchar(255))
go--演示用的数据表
create table test(id int)
go--记录操作的触发器
create trigger t_update on test
for insert,update,delete
as
insert t_log(事件类型,参数,执行的语句) exec('dbcc inputbuffer(@@spid)')
go--初始化表
insert into test values(1)
goupdate test set id=100
go--显示记录情况
select * from t_log
go--删除演示环境
drop table t_log,test