Skip to content

Instantly share code, notes, and snippets.

@MarkPryceMaherMSFT
Last active December 11, 2025 16:52
Show Gist options
  • Select an option

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

Select an option

Save MarkPryceMaherMSFT/1374d25fad7575463e3a641b68a12116 to your computer and use it in GitHub Desktop.
Query to monitor the activity from Mirroring
-- Create Extended Events session
CREATE EVENT SESSION [MonitorTableQueries]
ON SERVER
ADD EVENT sqlserver.sql_statement_completed
(
ACTION (
sqlserver.sql_text,
sqlserver.database_name,
sqlserver.username
)
WHERE (
sqlserver.database_name = N'mirroringlotsoftables' -- replace with your database
-- AND sqlserver.sql_text LIKE '%tbl_%' -- if you are just interested in a specific table
AND sqlserver.username = N'YourAdminUser' -- filter this to the user used to Mirror
)
)
ADD TARGET package0.event_file
(
SET filename = 'C:\XE\MonitorTableQueries.xel',
max_file_size = 10,
max_rollover_files = 50
)
WITH (
MAX_MEMORY = 4096 KB,
EVENT_RETENTION_MODE = ALLOW_SINGLE_EVENT_LOSS,
MAX_DISPATCH_LATENCY = 30 SECONDS,
TRACK_CAUSALITY = ON,
STARTUP_STATE = OFF
);
GO
-- Start the session
ALTER EVENT SESSION [MonitorTableQueries] ON SERVER STATE = START;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment