patternsqlMinor
Can SQL Server 2008 R2 extended events execute stored procedure or query?
Viewed 0 times
storedcan2008eventssqlqueryextendedprocedureserverexecute
Problem
I'm trying to use extended events to track queries that never complete using Event Pairing as a target. (see this question I asked a few days ago). The event pairing target should let me find queries that started but never completed.
My new problem is that I need to know what else was happening on the server when this event happens. I'd like to execute a stored procedure like sp_who, sp_who2, sp_WhoIsActive, etc. whenever I find a query that has not completed in 20+ seconds, for example. Is this possible?
My new problem is that I need to know what else was happening on the server when this event happens. I'd like to execute a stored procedure like sp_who, sp_who2, sp_WhoIsActive, etc. whenever I find a query that has not completed in 20+ seconds, for example. Is this possible?
Solution
Out of the box, no.
You'd need to hook into the event stream for extended events and then take action based on that. Tom Stringer has a good overview and sample code to do this!
See also Introducing the Extended Events Reader by Mike Wachal.
Jonathan Kehayias also describes it in detail in his Pluralsight course.
You'd need to hook into the event stream for extended events and then take action based on that. Tom Stringer has a good overview and sample code to do this!
See also Introducing the Extended Events Reader by Mike Wachal.
Jonathan Kehayias also describes it in detail in his Pluralsight course.
Context
StackExchange Database Administrators Q#97194, answer score: 8
Revisions (0)
No revisions yet.