查看触发器以在选择时将数据发送到历史记录 [英] View Trigger to send Data to History when SELECTed

查看:60
本文介绍了查看触发器以在选择时将数据发送到历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有一个VIEW,它是复杂过程的底层(详细数据)。我想在每次选择视图时将信息添加到历史记录表。



理想情况下,我希望在发布或关闭VIEW时执行它,类似于OnClose事件。我知道还有其他方法,我现在有一个方法,从客户端调用,但更喜欢有一个不需要管理的服务器端解决方案。



可能已经有一个内置函数或触发器方法来处理这个问题,如果是这样,我就找不到它。



任何帮助或提示都会非常感谢!

Hi All,

I have a VIEW that is the bottom layer (detailed data) of a complex process. I would like to add the information to a History Table each time the View is Selected.

Ideally, I would like for it to execute when the VIEW is released or Closed, similar to an OnClose event. I know there are other methods and I have one in place now, which is called from the Client Side, but would prefer to have a Server Side Solution that requires no management whatsoever.

There may already be a built-in Function or Trigger Method to handle this, and if so, I just cannot find it.

Any help or hints would be greatly appreciated!

推荐答案

SQL不提供select的触发器,但自2008年以来,您可以创建一个审计对象来记录服务器/数据库事件,如select ...

http://blogs.msdn.com/b/sreekarm/archive/2009/01/05/auditing-select-statements-in-sql-server-2008.aspx [ ^ ]

但是!请记住,读取次数(select)比写入(插入,更新,删除)大一些 - 并且原因触发器不支持select。因此,您尝试创建的此类日志将比原始表格大百倍,并且可能成为严重的空间/性能问题。因此,请考虑一个可扩展的日志数据库设计并仅记录真正必要的数据!!!
SQL does not provide trigger on select, but since 2008 you can create an audit object to log server/database events like select...
http://blogs.msdn.com/b/sreekarm/archive/2009/01/05/auditing-select-statements-in-sql-server-2008.aspx[^]
However! Remember that the number of reads (select) is a magnitude larger than writes (insert, update, delete) - and that the reason triggers do not support select. So such log you try to create will be huge hundredfold times than the original table and can became a serious space/performance problem. So think of a scale-able design for you log database and log only the really necessary data!!!


这篇关于查看触发器以在选择时将数据发送到历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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