Skip to content

Instantly share code, notes, and snippets.

@MarkPryceMaherMSFT
Created December 11, 2025 16:54
Show Gist options
  • Select an option

  • Save MarkPryceMaherMSFT/ceb3d73af8455cef335a0b001475b7b7 to your computer and use it in GitHub Desktop.

Select an option

Save MarkPryceMaherMSFT/ceb3d73af8455cef335a0b001475b7b7 to your computer and use it in GitHub Desktop.
query to look at extended events
SELECT
X.event_xml.value('(event/@name)[1]', 'varchar(50)') AS EventName,
X.event_xml.value('(event/action[@name="sql_text"]/value)[1]', 'nvarchar(max)') AS SQLText,
X.event_xml.value('(event/action[@name="database_name"]/value)[1]', 'varchar(128)') AS DatabaseName,
X.event_xml.value('(event/action[@name="username"]/value)[1]', 'varchar(128)') AS UserName,
X.event_xml.value('(event/@timestamp)[1]', 'datetime') AS EventTime
FROM sys.fn_xe_file_target_read_file('C:\XE\MonitorTableQueries*.xel', NULL, NULL, NULL) AS F
CROSS APPLY (SELECT CAST(F.event_data AS XML)) AS X(event_xml)
ORDER BY EventTime DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment