Script an Extended Event Session
This topic describes how to script an event session. You can export, alter, or drop the event session, or drop and create the event session to the following:
New Query Editor Window
File
Clipboard
Agent Job
To script an existing event session
In Object Explorer, expand the Management node, and then expand Extended Events.
Right-click the session you want to script, point to Script Session as, point to CREATE to, and then select where you want to script the session.
To script a new event session
In Object Explorer, expand the Management node, and then expand Extended Events.
Right-click Sessions, and then click New Session.
In the New Session UI, create the event session, and then select where you want to script the event session from the Script drop-down list.
To script a modified event session
In Object Explorer, expand the Management node, and then expand Extended Events.
Right-click the session you want to modify, and then click Properties.
In the Session Properties dialog box, modify the event session, and then select where you want to script the modified session from the Script drop-down list.