1

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

Pondlife
  • 15,992
  • 6
  • 37
  • 51
beakersoft
  • 2,316
  • 6
  • 30
  • 40

1 Answers1

1

You can use extended events to fire on sqlserver.sql_statement_completed and filtered by the object_id of the trigger of interest to get the whole TSQL call stack.

See my answer here for comprehensive example code.

Community
  • 1
  • 1
Martin Smith
  • 438,706
  • 87
  • 741
  • 845