Last active
December 11, 2025 16:52
-
-
Save MarkPryceMaherMSFT/1374d25fad7575463e3a641b68a12116 to your computer and use it in GitHub Desktop.
Query to monitor the activity from Mirroring
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- 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