0

I am working on a database used by separate applications. One of these applications is updating two fields in a table but I can't work out what one and don't have the source code for all the applications.

I am wondering if it is possible to write a log (to another table or elsewhere) to what the last update statement made against the table in question was. E.g. to record all SQL that has attempted to update the table automatically...

AJM
  • 30,452
  • 47
  • 147
  • 238
  • 2
    Please have a look at/possible duplicate of [Creating audit triggers in SQL Server](http://stackoverflow.com/questions/1962398/creating-audit-triggers-in-sql-server) – NickyvV Apr 20 '15 at 09:40
  • 1
    Change Data Capture and Change Tracking are two techniques via which you can achieve this.. – Deepshikha Apr 20 '15 at 09:40
  • SQL Server has this facility built in, you should probably see if this suits your needs before re-inventing the wheel. [Change Data Capture and Other SQL Server Features](https://msdn.microsoft.com/en-us/library/cc645938.aspx) – GarethD Apr 20 '15 at 10:07
  • So you log the statement. How do you know which application it came from? – paparazzo Apr 20 '15 at 10:37

1 Answers1

0

create a trigger before update on this table. Also create a new table. In that trigger store values before and after update in to a newly created table

Fathah Rehman P
  • 7,353
  • 3
  • 36
  • 41