Till
now we have just initialized the event, the event as such is NOT running. We
will need to start the session. We will alter the session and the command looks
like:
alter
event
session
xEvents_Session
on
server
state
=
start
To
check our session state, you can query another set of DMVs which start with
sys.dm_xe_* as:
select
*
from
sys.dm_xe_sessions
where
name
like
'xEvents_Session'
Just
to make create an error by making a SELECT to a non-existent object like:
Select
*
from
ExtremeExperts
Output:
Msg
208, Level 16, State 1, Line 1
Invalid
object name 'ExtremeExperts'.
Just
make a note of the error number, level and state. To get the dump from the
buffer which our Extended Event added, just query them off the sessions DMV’s
like:
select
CAST(xet.target_data
as xml)
from sys.dm_xe_session_targets
xet
join
sys.dm_xe_sessions
xe
on
(xe.address
= xet.event_session_address)
where
xe.name
= 'xEvents_Session'
The
output looks like:

Thatz
it. As simple as it gets. Now for folks would want to undo the operations we
did in the article, just stop the event and drop the same. And the commands
are:
alter
event
session
xEvents_Session
on
server
state
=
stop
drop
event
session
xEvents_Session
on
server
Conclusion
We
just took a quick tour of Extended Events from basics to a simple demo of using
Extended Events. This in anyway doesn’t show the real power of what Extended
Events can achieve. In subsequent articles I will try to get a little deeper
with some niche scenario’s to use xEvents to troubleshoot and performance
tuning SQL Server. Do drop in your comments …