1

Basically I have created a new extended event session, and I want to schedule this to run for a specific time lets say 2:00 AM. Usually I would of written a script to create a trace and then been able to schedule it using SQL Agent as a job, but I'm new to using Extended Events and I would want to know how I can schedule a session to start capturing at a specific time.

ZeRaTuL_jF
  • 582
  • 2
  • 4
  • 20

1 Answers1

2

You can create the session at any moment using CREATE EVENT SESSION: this will only create the session, but won't start it. In your SQL Agent job you can start the session according to your schedule using this simple command:

ALTER EVENT SESSION session_name
ON SERVER
STATE = start;
spaghettidba
  • 529
  • 7
  • 17