如何检查sqlserver数据库更新了哪个表 [英] How to check sqlserver database which table updated

查看:119
本文介绍了如何检查sqlserver数据库更新了哪个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
如何检查SQL Server 2005或2008中哪个表和哪个字段已更新或更改

请帮助我...

Hello All
How to check which table and which field updated or changes in sql server 2005 or 2008

please help me ...

推荐答案

没有内置的方法来识别更改了哪个记录.您可以为所有表实施审核跟踪,并使用它来识别更改.

如果您想了解架构更改,即是否在表中添加或更改了新列,请检查sys.tables表中的modified_date列.
There is no built in way to identify which record was changed. You can implement audit trail for all the tables and use that to identify the changes.

If you are interested in knowing about the schema changes i.e. if a new column was added or altered in a table, check modified_date column in sys.tables table.


表结构然后使用,
用于表格修改
If you are talking about table structure then use,
for table modifiction
select Name,create_date,modify_date from sys.objects where type='u' 


如果列是这样的主键/外键,则可以获取列更新的日期


you can fetch column update''s date if column is primary key/foreign key like this

select Name,create_date,modify_date from sys.objects where type='p' or type='F'



对于所有列的修改日期,您都必须在表修改上添加触发器.并将条目保存在新表中.

注意:无论何时重命名列,都不会触发表修改触发器.因此,在这种情况下,您将无法保存重命名"列的更改.

祝您编码愉快!
:)



for all columns modification date, you have to put trigger on table modification. and save entries inside a new table.

Note: when ever you will rename column table-modification trigger will not be fired. so, that case you will not able to save ''renamed'' column''s changes.

Happy Coding!
:)


这篇关于如何检查sqlserver数据库更新了哪个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆