Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get SQL Profiler to monitor trigger execution

I have a trace setup for SQL Server Profiler to monitor SQL that is executed on a database. I recently discovered that trigger execution is not included in the trace. After looking through available events for a trace, I do not see any that look like they would include trigger execution. Does anyone know how to setup a trace to monitor the execution of triggers?

like image 587
firedfly Avatar asked Oct 01 '08 20:10

firedfly


People also ask

How do I trace triggers in SQL Profiler?

In SQL Server Profiler 2008, when starting/configuring the trace, go to the "Events Selection" tab, click on the "Show all events" checkbox, and then in the list under the Stored Procedures section select the SP:StmtStarting and SP:StmtCompleted events to be included in the trace.

How do you check if trigger is executed in SQL Server?

To test if a trigger fires you can add a PRINT statement to the trigger (e.g. "PRINT 'trigger fired!' "), then do something that should trigger the trigger. If you get the printed text in your messages-tab in management studio you know it fired.

How do I check my DB triggers?

To view database level triggers, Login to the server using SQL Server management studio and navigate to the database. Expand the database and navigate to Programmability -> Database Triggers. To view triggers at the server level, Login to Server using SSMS and navigate to Server Objects and then Triggers folder.


2 Answers

Stored procedures: - SP:StmtStarting - SP:StmtCompleted

like image 130
Mladen Avatar answered Oct 03 '22 00:10

Mladen


In SQL Server Profiler 2008, when starting/configuring the trace, go to the "Events Selection" tab, click on the "Show all events" checkbox, and then in the list under the Stored Procedures section select the SP:StmtStarting and SP:StmtCompleted events to be included in the trace.

like image 37
Lachlan Wetherall Avatar answered Oct 03 '22 00:10

Lachlan Wetherall