如何查找SQL SERVER中最后一次修改的表记录

我用程序修改了SQL SERVER数据库中的表,但是由于程序问题,我发现要修改的表没有修改,可能别的表被修改了,如何查找我修改的是哪个表,即最后一次修改的表是哪个?
tjoy7d,你的答案好象是用来查询错误日志记录的噢,只有错误的才会显示出来
wb1123,不是某一个表,而是数据库中不知道修改了哪个表,所以不能用这个命令噢,谢谢.

查看一下SQL Server的日志不就可以了:)

进入企业管理器,你的数据库点开,"管理">>"SQL Server日志",查看你那天的存档就可以了。

唉,我可没有说右击阿:)

你点开你的数据库,下面不是有一些选项么,"数据库","数据转换服务","管理"......就是这个管理阿。
温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2016-04-06
1.--建立记录时间表
if object_id('RecordLastDate') is not null drop table RecordLastDate
go
create table RecordLastDate(tbname varchar(50),lastdate datetime)
insert into RecordLastDate select name,null from sysobjects where type='u' and status >=0 and name<>'RecordLastDate'
go
2.--建立用户表
if object_id('tb_test') is not null drop table tb_test
go
create table tb_test(c1 varchar(10))
go
3.--建立触发器
if object_id('tr_1') is not null drop trigger tr_1
go
create trigger tr_1 on tb_test
for insert,delete
as
if exists(select 1 from inserted) or exists(select 1 from deleted)
update RecordLastDate set lastdate=getdate() where tbname='tb_test'
go
4.--测试插入记录
insert tb_test values('abc')
insert tb_test values('def')
5.--查看时间记录表
select * from RecordLastDate where tbname='tb_test'
go
waitfor delay '00:00:05'
go
6.--测试删除记录
insert tb_test values('def')
--查看时间记录表
select * from RecordLastDate where tbname='tb_test'
go
--查看结果
/*
tbname lastdate
-----------------------------------------------
tb_test 2015-08-11 15:25:37.107
tbname lastdate
-----------------------------------------------
tb_test 2015-08-11 15:25:42.123
*/
第2个回答  2005-12-22
select top1 from xx order by xxx desc
相似回答