如何列出数据库中有更改的表的名称(插入新记录,更新或删除记录) [英] How do I list down the names of tables in my database that has changes (new record inserted, record updated or deleted)
本文介绍了如何列出数据库中有更改的表的名称(插入新记录,更新或删除记录)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个MS SQL Server Express版本,我想知道我的应用程序是通过我的数据库编码的新产品,还是用户编码新员工或更改员工信息。我希望这些更改存储在另一个表中,这样我就可以很容易地看到那些是什么以及来自哪些表。
我尝试了什么: < br $>
i正在考虑为此创建触发器,但这需要我为每个表添加触发器。如果有数据库更改的触发器?
i have an MS SQL Server Express edition, and i want to know if there were new products encoded in my application thru my database, or if user encoded new employees or change employee information. i want those changes stored in another table so i can easily see what are those and from which tables.
What I have tried:
i was thinking of creating a trigger for this but that would require me to add triggers to each tables. if there's a trigger for the changes in database?
推荐答案
嗨JOVY,
请关注此林解释了表格中插入,更新,删除的触发器,你也可以找到样本表和脚本。
Trigger-Insert,Update,Delete in tables
谢谢
:)
Hi JOVY,
Please follow this lin explained about trigger for insert,update,delete in tables and you can find the sample table and script also.
Trigger-Insert,Update,Delete in tables
Thanks
:)
SELECT
[db_name] = d.name
, [table_name] = SCHEMA_NAME(o.[schema_id]) + '.' + o.name
, s.last_user_update
FROM sys.dm_db_index_usage_stats s
JOIN sys.databases d ON s.database_id = d.database_id
JOIN sys.objects o ON s.[object_id] = o.[object_id]
WHERE o.[type] = 'U'
AND s.last_user_update IS NOT NULL
AND s.last_user_update BETWEEN DATEADD(wk, -1, GETDATE()) AND GETDATE()
这篇关于如何列出数据库中有更改的表的名称(插入新记录,更新或删除记录)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文