找出哪个应用程序正在更改 SQL 数据库值
我遇到了一个问题,许多应用程序读/写的遗留数据库不断变化,而且我无法弄清楚是什么在改变它。
我的应用程序更改了表中某一行中的某个值,但大约一周后,有些东西不断将其更改回来,我很难弄清楚它可能是什么。
有什么方法可以将事件/触发器附加到该值上,然后让它存储/通过电子邮件发送更改它的详细信息?或者至少什么时间改变的?
I'm running into an issue where the legacy database that many applications read/write to keeps getting changed, and I can't work out what is changing it.
My application changes a certain value in a certain row of the table, but something keeps changing it back after a week or so and I'm stumped to work out what it could be.
Is there any way I can attach an event/trigger onto this value and then have it store/email the details of what changed it ? or at least what time it was changed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您有权访问旧应用程序的连接字符串,请将
Application Name
关键字添加到连接字符串中。 这里有一些信息.在服务器端为您要跟踪的表创建一个触发器。在触发日志
app_name()
到日志表中。像这样:此外,如果每个应用程序有一个专用用户,您可以检查并记录
system_user
值。如果您的应用程序托管在不同的服务器上,您也可以添加客户端 IP。您可以这样检查
select client_net_address from sys.dm_exec_connections where session_id = @@SPID
。此外,您可以使用探查器来查看所有这些参数。
但所有这些都需要注意,您可以更新连接字符串。
If you have access to connection strings for your legacy applications add
Application Name
keyword to connection string. Some info here.On the server side create a trigger for the table you want to track. In the trigger log
app_name()
into a log table. Like this:Also, if you have a dedicated user per application you could check and log
system_user
value.If your applications hosted by different servers you can add client IP too. You can check it like this
select client_net_address from sys.dm_exec_connections where session_id = @@SPID
.Also, you can use profiler to see all those parameters.
But all this with the caveat you can update your connection strings.