We are trying to do a bit more logging on a database table. We have got a trigger that works on the delete of a row, and would like to record the SQL that has caused this trigger to run.
We’ve had a look around and cant see anything that will reliably accomplish this, has anyone ever managed to do this? we are running SQL 2008.
Cheers
Luke
You can use extended events to fire on
sqlserver.sql_statement_completedand filtered by theobject_idof the trigger of interest to get the whole TSQL call stack.See my answer here for comprehensive example code.