1. <small id='vgIjB'></small><noframes id='vgIjB'>

    • <bdo id='vgIjB'></bdo><ul id='vgIjB'></ul>
    <i id='vgIjB'><tr id='vgIjB'><dt id='vgIjB'><q id='vgIjB'><span id='vgIjB'><b id='vgIjB'><form id='vgIjB'><ins id='vgIjB'></ins><ul id='vgIjB'></ul><sub id='vgIjB'></sub></form><legend id='vgIjB'></legend><bdo id='vgIjB'><pre id='vgIjB'><center id='vgIjB'></center></pre></bdo></b><th id='vgIjB'></th></span></q></dt></tr></i><div id='vgIjB'><tfoot id='vgIjB'></tfoot><dl id='vgIjB'><fieldset id='vgIjB'></fieldset></dl></div>
  2. <tfoot id='vgIjB'></tfoot>

    1. <legend id='vgIjB'><style id='vgIjB'><dir id='vgIjB'><q id='vgIjB'></q></dir></style></legend>

      创建触发器来记录影响表的 SQL?

      Create Trigger to log SQL that affected table?(创建触发器来记录影响表的 SQL?)
      <tfoot id='aWwgS'></tfoot>
            <tbody id='aWwgS'></tbody>
          <legend id='aWwgS'><style id='aWwgS'><dir id='aWwgS'><q id='aWwgS'></q></dir></style></legend>

            • <bdo id='aWwgS'></bdo><ul id='aWwgS'></ul>

              <i id='aWwgS'><tr id='aWwgS'><dt id='aWwgS'><q id='aWwgS'><span id='aWwgS'><b id='aWwgS'><form id='aWwgS'><ins id='aWwgS'></ins><ul id='aWwgS'></ul><sub id='aWwgS'></sub></form><legend id='aWwgS'></legend><bdo id='aWwgS'><pre id='aWwgS'><center id='aWwgS'></center></pre></bdo></b><th id='aWwgS'></th></span></q></dt></tr></i><div id='aWwgS'><tfoot id='aWwgS'></tfoot><dl id='aWwgS'><fieldset id='aWwgS'></fieldset></dl></div>

            • <small id='aWwgS'></small><noframes id='aWwgS'>

                本文介绍了创建触发器来记录影响表的 SQL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我试图找出更新列值的内容,但我对该应用程序知之甚少.快速浏览一下,我注意到大约 90% 的应用程序业务逻辑是在数据库上处理的.毋庸置疑,SP、功能和触发器的深度是疯狂的.

                I'm trying to find out what is updating the value of a column and i have very little knowledge of the application. At a quick glance I've noticed about 90% of the applications business logic is handled on the database. Needless to say the depth of SP's, functions, and triggers is crazy.

                我想在有问题的表上创建一个触发器,以记录影响该表的 SQL.可以使用什么 SQL 来获取正在更新的表的上下文中执行的 SQL?

                I'd like to create a trigger on the table in question that will log the SQL that affected the table. What SQL could be used to grab the executed SQL in the context of the table being updated?

                详情:微软 SQL Server 2008

                Details: MS SQL Server 2008

                谢谢!!

                推荐答案

                我的解决方案

                我在有问题的表上添加了一个触发器,记录了我通过 sys.dm_exec_sql_textsys.dm_exec_query_stats 的时间戳缩小范围的信息.这很快就确定了我正在寻找的东西.结果发现有一些我不知道的触发器是在 UPDATE 后更新数据.

                My Solution

                I added a trigger on the table in question that logged information i narrowed down via timestamps from sys.dm_exec_sql_text AND sys.dm_exec_query_stats. This quickly nailed down what i was looking for. Turns out there were a few triggers i didn't know about that were updating data after a UPDATE.

                SELECT 
                    qStats.last_execution_time AS [ExecutedAt],
                    qTxt.[text] AS [Query], qTxt.number
                FROM
                    sys.dm_exec_query_stats AS qStats
                    CROSS APPLY
                    sys.dm_exec_sql_text(qStats.sql_handle) AS qTxt
                WHERE
                    qTxt.[dbid] = @DbId
                    AND qTxt.[text] like '%UPDATE%'
                    AND qStats.last_execution_time between @StartExecutionSearchTime and @EndExecutionSearchTime
                ORDER BY
                    qStats.last_execution_time DESC 
                

                这篇关于创建触发器来记录影响表的 SQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                SQL query to group by day(按天分组的 SQL 查询)
                What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                Include missing months in Group By query(在 Group By 查询中包含缺失的月份)

                  <tbody id='Nmggf'></tbody>
                <i id='Nmggf'><tr id='Nmggf'><dt id='Nmggf'><q id='Nmggf'><span id='Nmggf'><b id='Nmggf'><form id='Nmggf'><ins id='Nmggf'></ins><ul id='Nmggf'></ul><sub id='Nmggf'></sub></form><legend id='Nmggf'></legend><bdo id='Nmggf'><pre id='Nmggf'><center id='Nmggf'></center></pre></bdo></b><th id='Nmggf'></th></span></q></dt></tr></i><div id='Nmggf'><tfoot id='Nmggf'></tfoot><dl id='Nmggf'><fieldset id='Nmggf'></fieldset></dl></div>
                    <bdo id='Nmggf'></bdo><ul id='Nmggf'></ul>

                        <legend id='Nmggf'><style id='Nmggf'><dir id='Nmggf'><q id='Nmggf'></q></dir></style></legend>

                        <tfoot id='Nmggf'></tfoot>
                        • <small id='Nmggf'></small><noframes id='Nmggf'>