Created
November 18, 2025 19:33
-
-
Save MarkPryceMaherMSFT/203b67eaf41c9244fb2bff3e8cde68ae to your computer and use it in GitHub Desktop.
Clean up evented events
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
| -- Stop the Extended Events session if it is running | |
| IF EXISTS ( | |
| SELECT 1 | |
| FROM sys.server_event_sessions | |
| WHERE name = 'MonitorTableQueries' | |
| ) | |
| BEGIN | |
| ALTER EVENT SESSION [MonitorTableQueries] ON SERVER STATE = STOP; | |
| PRINT 'MonitorTableQueries session stopped.'; | |
| END | |
| ELSE | |
| BEGIN | |
| PRINT 'MonitorTableQueries session does not exist or is already stopped.'; | |
| END | |
| GO | |
| -- Drop the Extended Events session | |
| IF EXISTS ( | |
| SELECT 1 | |
| FROM sys.server_event_sessions | |
| WHERE name = 'MonitorTableQueries' | |
| ) | |
| BEGIN | |
| DROP EVENT SESSION [MonitorTableQueries] ON SERVER; | |
| PRINT 'MonitorTableQueries session dropped successfully.'; | |
| END | |
| ELSE | |
| BEGIN | |
| PRINT 'MonitorTableQueries session does not exist.'; | |
| END | |
| GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment