By: Ben Snaidero
Overview
In this section we will look at how find the current status of an extended events session and how to start and stop an extended events session.
Check Status of Extended Events Sessions Using TSQL
Before we get into how you can stop and start an extended event session let’s take a look at how we can first check on the status of each session and determine its current state. Using TSQL we can get this information from the sys.server_event_sessions table. The simple query below will show each event sessions state.
select name, startup_state from sys.server_event_sessions
Check Status of Extended Events Sessions Using SSMS
You can also get this information using SSMS by opening Object Explorer and expanding the “Management” node, then “Extended Events” and “Sessions”. Any session with the green play button icon is running and the red down arrow icon means the session is stopped.
Start or Stop Extended Events Session Using SSMS
Since we have Object Explorer open, if we want to start a stopped session using the GUI, we simply right-click on the session name as shown below and click "Start Session”. Similarly, to stop a running session, we do the same and click “Stop Session”.
Start or Stop Extended Events Session Using TSQL
Sessions can also be started and stopped using TSQL. The following commands perform each of these actions.
-- start a session ALTER EVENT SESSION First_XEvent_Session ON SERVER STATE = START; -- stop a session ALTER EVENT SESSION First_XEvent_Session ON SERVER STATE = STOP;
Additional Information
Last Update: 6/14/2019