{"id":533,"date":"2010-12-31T21:42:00","date_gmt":"2010-12-31T21:42:00","guid":{"rendered":"\/blogs\/jonathan\/post\/An-XEvent-a-Day-(31-of-31)-Event-Session-DDL-Events.aspx"},"modified":"2017-04-13T12:55:28","modified_gmt":"2017-04-13T16:55:28","slug":"an-xevent-a-day-31-of-31-event-session-ddl-events","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/an-xevent-a-day-31-of-31-event-session-ddl-events\/","title":{"rendered":"An XEvent a Day (31 of 31) &#8211; Event Session DDL Events"},"content":{"rendered":"<p>To close out this month\u2019s series on Extended Events we\u2019ll look at the DDL Events for the Event Session DDL operations, and how those can be used to track changes to Event Sessions and determine all of the possible outputs that could exist from an Extended Event Session.&#160; One of my least favorite quirks about Extended Events is that there is no way to determine the Events and Actions that may exist inside a Target, except to parse all of the the captured data.&#160; Information about the Event Session does exist in the <a href=\"https:\/\/www.sqlskills.com\/blogs\/jonathan\/an-xevent-a-day-4-of-31-querying-the-session-definition-and-active-session-dmvs\/\">Session Definition Catalog Views and Active Session DMV\u2019s<\/a>, but as you change an Event Sessions Events and Actions while it is running, the information in these change as well, so it is possible that a Target has Events and Actions that are not returned by the current information available about the Event Session.&#160; This is where the DDL Events for the Event Session DDL operations can be useful, if the appropriate framework is deployed.<\/p>\n<p>The DDL Events for Extended Events are not currently documented in the Books Online.&#160; I only recently learned about them from Mike Wachal during a discussion about what I thought was missing from Extended Events.&#160; This is simply an oversight in the documentation, and something that Mike has stated will be fixed, it doesn\u2019t mean that the DDL Events are undocumented and subject to change without notice like other undocumented features of SQL Server.&#160; We can find the DDL Events for Extended Events in the sys.event_notification_event_types.<\/p>\n<blockquote>\n<pre class=\"code\"><span style=\"color: blue\">SELECT\r\n    type<\/span><span style=\"color: gray\">,\r\n    <\/span><span style=\"color: magenta\">type_name<\/span><span style=\"color: gray\">,\r\n    <\/span><span style=\"color: teal\">parent_type\r\n<\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: green\">sys<\/span><span style=\"color: gray\">.<\/span><span style=\"color: green\">event_notification_event_types\r\n<\/span><span style=\"color: blue\">WHERE <\/span><span style=\"color: magenta\">type_name <\/span><span style=\"color: gray\">LIKE <\/span><span style=\"color: red\">'%SESSION%'\r\n<\/span><\/pre>\n<\/blockquote>\n<blockquote>\n<p><a href=\"https:\/\/www.SQLskills.com\/blogs\/jonathan\/wp-content\/uploads\/windowslivewriter\/anxeventaday31of31eventsessionddlevents\/241fd340\/image.png\"><img decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/www.SQLskills.com\/blogs\/jonathan\/wp-content\/uploads\/windowslivewriter\/anxeventaday31of31eventsessionddlevents\/43627a13\/image_thumb.png\" width=\"341\" height=\"101\" \/><\/a> <\/p>\n<\/blockquote>\n<p>These can be used just like any other DDL Event to create a DDL Trigger or Event Notification that takes action when one of the DDL operations occurs.&#160; We can use this to log the DDL to track our changes over time, and we can also use it to create a tracking table of the possible outputs from our Event Session, ensuring that we know what information it may have collected when we parse the Event data from the Targets.&#160; We can also use this information to simplify the generation of our XQuery XPATH statements to parse the data from the Targets with a little extra work.&#160; <\/p>\n<p>In all of my servers, I have a standard database named sqladmin that I keep DBA related information and objects.&#160; For the examples, I will create this database and use it in all the code.&#160; If you have a different database, the scripts can easily be changed to create the objects in that database.&#160; The first thing we\u2019ll do is create our database, and two tables, one for tracking the DDL operations and the other for tracking all of the possible outputs for our Event Session.<\/p>\n<blockquote>\n<pre class=\"code\"><span style=\"color: blue\">CREATE DATABASE <\/span>sqladmin\r\n<span style=\"color: blue\">GO\r\nUSE <\/span>sqladmin\r\n<span style=\"color: blue\">GO\r\nCREATE TABLE <\/span>dbo<span style=\"color: gray\">.<\/span>XEvents_DDLOperations\r\n<span style=\"color: gray\">( <\/span>DDLEventData <span style=\"color: blue\">XML<\/span><span style=\"color: gray\">, \r\n  <\/span>ChangeDate <span style=\"color: blue\">DATETIME DEFAULT<\/span><span style=\"color: gray\">(<\/span><span style=\"color: magenta\">CURRENT_TIMESTAMP<\/span><span style=\"color: gray\">), \r\n  <\/span>LoginName <span style=\"color: blue\">NVARCHAR<\/span><span style=\"color: gray\">(<\/span>256<span style=\"color: gray\">) <\/span><span style=\"color: blue\">DEFAULT<\/span><span style=\"color: gray\">(<\/span><span style=\"color: magenta\">SUSER_SNAME<\/span><span style=\"color: gray\">()),\r\n  <\/span>ProgramName <span style=\"color: blue\">NVARCHAR<\/span><span style=\"color: gray\">(<\/span>256<span style=\"color: gray\">) <\/span><span style=\"color: blue\">DEFAULT<\/span><span style=\"color: gray\">(<\/span><span style=\"color: magenta\">program_name<\/span><span style=\"color: gray\">())\r\n);\r\n<\/span><span style=\"color: blue\">GO\r\nCREATE TABLE <\/span>XEvents_SessionOutputs\r\n<span style=\"color: gray\">(\r\n    <\/span>EventSessionName <span style=\"color: blue\">NVARCHAR<\/span><span style=\"color: gray\">(<\/span>256<span style=\"color: gray\">),\r\n    <\/span>EventName <span style=\"color: blue\">NVARCHAR<\/span><span style=\"color: gray\">(<\/span>256<span style=\"color: gray\">),\r\n    <\/span>EventID <span style=\"color: blue\">INT<\/span><span style=\"color: gray\">,\r\n    <\/span>ColumnID <span style=\"color: blue\">INT<\/span><span style=\"color: gray\">,\r\n    <\/span>ColumnName <span style=\"color: blue\">NVARCHAR<\/span><span style=\"color: gray\">(<\/span>256<span style=\"color: gray\">),\r\n    <\/span>NodeType <span style=\"color: blue\">NVARCHAR<\/span><span style=\"color: gray\">(<\/span>10<span style=\"color: gray\">),\r\n    <\/span>DataType <span style=\"color: blue\">NVARCHAR<\/span><span style=\"color: gray\">(<\/span>50<span style=\"color: gray\">),\r\n    <\/span>XMLLocation <span style=\"color: blue\">NVARCHAR<\/span><span style=\"color: gray\">(<\/span>10<span style=\"color: gray\">),\r\n    <\/span>TypePrecidence <span style=\"color: blue\">INT\r\n<\/span><span style=\"color: gray\">)\r\n<\/span><span style=\"color: blue\">GO<\/span><\/pre>\n<\/blockquote>\n<p><a href=\"http:\/\/www.11011.net\/software\/vspaste\"><\/a>The XEvents_SessionOutputs table will have multiple rows for each Event Session defined on the server that track the EventName, the output ColumnName, the NodeType for the data element in the Event XML, the SQL DataType returned by the output, the XMLLocation for where the data of interest exists, and a TypePrecidence value that can be used when multiple Events return the same Data Element with different DataTypes, ensuring that we can pick the most compatible DataType for the output column.&#160; The table also tracks the Event ID in the Event Session for the Event, the Column ID for the output column so that grouping and ordering can be performed during code generation from this table.<\/p>\n<p>To get the SQL DataType that an output returns, we have to look at the output type_name in the Extended Events metadata for the output column or Action.&#160; To make this easier to do and allow for code reuse, I create a view that maps the type_name in Extended Events to corresponding SQL DataType.&#160; Since Maps can be a type_name in Extended Events, the view queries the sys.dm_xe_map_values DMV and calculates the maximum length of the map_value column for each Map, and then uses the nvarchar datatype and rounds the length up to the nearest power of 10 (ok, it doesn\u2019t actually round but that is the effect of the math operations).&#160; For the actual Event data columns in the base payload, the type_name is transposed to the equivalent SQL DataType that is compatible with XQuery.<\/p>\n<blockquote>\n<pre class=\"code\"><span style=\"color: blue\">CREATE VIEW <\/span>dbo<span style=\"color: gray\">.<\/span>XETypeToSQLType \r\n<span style=\"color: blue\">AS\r\n    SELECT \r\n        <\/span>XETypeName <span style=\"color: gray\">= <\/span>mv<span style=\"color: gray\">.<\/span>name<span style=\"color: gray\">, \r\n        <\/span>SQLTypeName <span style=\"color: gray\">= <\/span><span style=\"color: red\">'nvarchar('<\/span><span style=\"color: gray\">+<\/span><span style=\"color: magenta\">CAST<\/span><span style=\"color: gray\">(<\/span><span style=\"color: magenta\">MAX<\/span><span style=\"color: gray\">(<\/span><span style=\"color: magenta\">LEN<\/span><span style=\"color: gray\">(<\/span>mv<span style=\"color: gray\">.<\/span>map_value<span style=\"color: gray\">))-(<\/span><span style=\"color: magenta\">MAX<\/span><span style=\"color: gray\">(<\/span><span style=\"color: magenta\">LEN<\/span><span style=\"color: gray\">(<\/span>mv<span style=\"color: gray\">.<\/span>map_value<span style=\"color: gray\">))%<\/span>10<span style=\"color: gray\">) + <\/span>10 <span style=\"color: blue\">AS VARCHAR<\/span><span style=\"color: gray\">(<\/span>4<span style=\"color: gray\">))+<\/span><span style=\"color: red\">')'<\/span><span style=\"color: gray\">,\r\n        <\/span>XMLLocation <span style=\"color: gray\">= <\/span><span style=\"color: red\">'text'<\/span><span style=\"color: gray\">,\r\n        <\/span>TypePrecidence <span style=\"color: gray\">= <\/span>5\r\n    <span style=\"color: blue\">FROM <\/span><span style=\"color: green\">sys<\/span><span style=\"color: gray\">.<\/span><span style=\"color: green\">dm_xe_object_columns <\/span>oc\r\n    <span style=\"color: gray\">LEFT JOIN <\/span><span style=\"color: green\">sys<\/span><span style=\"color: gray\">.<\/span><span style=\"color: green\">dm_xe_map_values <\/span>mv\r\n        <span style=\"color: blue\">ON <\/span>oc<span style=\"color: gray\">.<\/span>type_package_guid <span style=\"color: gray\">= <\/span>mv<span style=\"color: gray\">.<\/span>object_package_guid\r\n            <span style=\"color: gray\">AND <\/span>oc<span style=\"color: gray\">.<\/span><span style=\"color: magenta\">type_name <\/span><span style=\"color: gray\">= <\/span>mv<span style=\"color: gray\">.<\/span>name\r\n    <span style=\"color: blue\">WHERE <\/span>oc<span style=\"color: gray\">.<\/span>column_type <span style=\"color: gray\">= <\/span><span style=\"color: red\">'data'\r\n      <\/span><span style=\"color: gray\">AND <\/span>mv<span style=\"color: gray\">.<\/span>name <span style=\"color: gray\">IS NOT NULL\r\n    <\/span><span style=\"color: blue\">GROUP BY <\/span>mv<span style=\"color: gray\">.<\/span>name\r\n<span style=\"color: blue\">UNION <\/span><span style=\"color: gray\">ALL\r\n    <\/span><span style=\"color: blue\">SELECT \r\n        <\/span>XETypeName <span style=\"color: gray\">= <\/span>o<span style=\"color: gray\">.<\/span>name<span style=\"color: gray\">,\r\n        <\/span>SQLTypeName <span style=\"color: gray\">= <\/span><span style=\"color: blue\">CASE \r\n                            WHEN <\/span><span style=\"color: magenta\">TYPE_NAME <\/span><span style=\"color: gray\">IN (<\/span><span style=\"color: red\">'int8'<\/span><span style=\"color: gray\">, <\/span><span style=\"color: red\">'int16'<\/span><span style=\"color: gray\">, <\/span><span style=\"color: red\">'int32'<\/span><span style=\"color: gray\">, <\/span><span style=\"color: red\">'uint8'<\/span><span style=\"color: gray\">, \r\n                                    <\/span><span style=\"color: red\">'uint16'<\/span><span style=\"color: gray\">, <\/span><span style=\"color: red\">'uint32'<\/span><span style=\"color: gray\">, <\/span><span style=\"color: red\">'float32'<\/span><span style=\"color: gray\">) \r\n                                <\/span><span style=\"color: blue\">THEN <\/span><span style=\"color: red\">'int'\r\n                            <\/span><span style=\"color: blue\">WHEN <\/span><span style=\"color: magenta\">TYPE_NAME <\/span><span style=\"color: gray\">IN (<\/span><span style=\"color: red\">'int64'<\/span><span style=\"color: gray\">, <\/span><span style=\"color: red\">'uint64'<\/span><span style=\"color: gray\">, <\/span><span style=\"color: red\">'float64'<\/span><span style=\"color: gray\">)\r\n                                <\/span><span style=\"color: blue\">THEN <\/span><span style=\"color: red\">'bigint'\r\n                            <\/span><span style=\"color: blue\">WHEN <\/span><span style=\"color: magenta\">TYPE_NAME <\/span><span style=\"color: gray\">= <\/span><span style=\"color: red\">'boolean'\r\n                                <\/span><span style=\"color: blue\">THEN <\/span><span style=\"color: red\">'nvarchar(10)' <\/span><span style=\"color: green\">--true\/false returned\r\n                            <\/span><span style=\"color: blue\">WHEN <\/span><span style=\"color: magenta\">TYPE_NAME <\/span><span style=\"color: gray\">= <\/span><span style=\"color: red\">'guid'\r\n                                <\/span><span style=\"color: blue\">THEN <\/span><span style=\"color: red\">'uniqueidentifier'\r\n                            <\/span><span style=\"color: blue\">ELSE <\/span><span style=\"color: red\">'nvarchar(4000)'\r\n                        <\/span><span style=\"color: blue\">END<\/span><span style=\"color: gray\">,\r\n        <\/span>XMLLocation <span style=\"color: gray\">= <\/span><span style=\"color: red\">'value'<\/span><span style=\"color: gray\">,\r\n        <\/span>TypePrecidence <span style=\"color: gray\">= <\/span><span style=\"color: blue\">CASE \r\n                            WHEN <\/span><span style=\"color: magenta\">TYPE_NAME <\/span><span style=\"color: gray\">IN (<\/span><span style=\"color: red\">'int8'<\/span><span style=\"color: gray\">, <\/span><span style=\"color: red\">'int16'<\/span><span style=\"color: gray\">, <\/span><span style=\"color: red\">'int32'<\/span><span style=\"color: gray\">, <\/span><span style=\"color: red\">'uint8'<\/span><span style=\"color: gray\">, \r\n                                    <\/span><span style=\"color: red\">'uint16'<\/span><span style=\"color: gray\">, <\/span><span style=\"color: red\">'uint32'<\/span><span style=\"color: gray\">, <\/span><span style=\"color: red\">'float32'<\/span><span style=\"color: gray\">) \r\n                                <\/span><span style=\"color: blue\">THEN <\/span>1\r\n                            <span style=\"color: blue\">WHEN <\/span><span style=\"color: magenta\">TYPE_NAME <\/span><span style=\"color: gray\">IN (<\/span><span style=\"color: red\">'int64'<\/span><span style=\"color: gray\">, <\/span><span style=\"color: red\">'uint64'<\/span><span style=\"color: gray\">, <\/span><span style=\"color: red\">'float64'<\/span><span style=\"color: gray\">)\r\n                                <\/span><span style=\"color: blue\">THEN <\/span>2\r\n                            <span style=\"color: blue\">WHEN <\/span><span style=\"color: magenta\">TYPE_NAME <\/span><span style=\"color: gray\">= <\/span><span style=\"color: red\">'boolean'\r\n                                <\/span><span style=\"color: blue\">THEN <\/span>3 <span style=\"color: green\">--true\/false returned\r\n                            <\/span><span style=\"color: blue\">WHEN <\/span><span style=\"color: magenta\">TYPE_NAME <\/span><span style=\"color: gray\">= <\/span><span style=\"color: red\">'guid'\r\n                                <\/span><span style=\"color: blue\">THEN <\/span>3\r\n                            <span style=\"color: blue\">ELSE <\/span>5\r\n                         <span style=\"color: blue\">END\r\n    FROM <\/span><span style=\"color: green\">sys<\/span><span style=\"color: gray\">.<\/span><span style=\"color: green\">dm_xe_objects <\/span>o\r\n    <span style=\"color: blue\">WHERE <\/span>object_type <span style=\"color: gray\">= <\/span><span style=\"color: red\">'type'\r\n      <\/span><span style=\"color: gray\">AND <\/span><span style=\"color: magenta\">TYPE_NAME <\/span><span style=\"color: gray\">!= <\/span><span style=\"color: red\">'null'\r\n<\/span><span style=\"color: blue\">GO<\/span><\/pre>\n<\/blockquote>\n<p>Using this view, we can create another view that queries the Session Definition Catalog Views, to retrieve the output columns for an Event Session in a format that matches our XEvents_SessionOutputs table.<\/p>\n<blockquote>\n<pre class=\"code\"><span style=\"color: blue\">CREATE VIEW <\/span>dbo<span style=\"color: gray\">.<\/span>XESession_OutputsFromDMVs\r\n<span style=\"color: blue\">AS\r\n        <\/span><span style=\"color: green\">-- Find a list of all the possible output columns\r\n        <\/span><span style=\"color: blue\">SELECT \r\n            <\/span>ses<span style=\"color: gray\">.<\/span>name <span style=\"color: blue\">AS <\/span>EventSessionName<span style=\"color: gray\">,\r\n            <\/span>sese<span style=\"color: gray\">.<\/span>name <span style=\"color: blue\">AS <\/span>EventName<span style=\"color: gray\">,\r\n            <\/span>sese<span style=\"color: gray\">.<\/span>event_id <span style=\"color: blue\">AS <\/span>EventID<span style=\"color: gray\">,\r\n            <\/span>oc<span style=\"color: gray\">.<\/span>column_id <span style=\"color: blue\">AS <\/span>ColumnID<span style=\"color: gray\">,\r\n            <\/span>oc<span style=\"color: gray\">.<\/span>name <span style=\"color: blue\">AS <\/span>ColumnName<span style=\"color: gray\">,\r\n            <\/span><span style=\"color: red\">'data' <\/span><span style=\"color: blue\">AS <\/span>NodeType<span style=\"color: gray\">,\r\n            <\/span>xetst<span style=\"color: gray\">.<\/span>SQLTypeName <span style=\"color: blue\">AS <\/span>DataType<span style=\"color: gray\">,\r\n            <\/span>xetst<span style=\"color: gray\">.<\/span>XMLLocation<span style=\"color: gray\">,\r\n            <\/span>xetst<span style=\"color: gray\">.<\/span>TypePrecidence\r\n        <span style=\"color: blue\">FROM <\/span><span style=\"color: green\">sys<\/span><span style=\"color: gray\">.<\/span><span style=\"color: green\">server_event_sessions <\/span><span style=\"color: blue\">AS <\/span>ses\r\n        <span style=\"color: gray\">JOIN <\/span><span style=\"color: green\">sys<\/span><span style=\"color: gray\">.<\/span><span style=\"color: green\">server_event_session_events <\/span><span style=\"color: blue\">AS <\/span>sese\r\n            <span style=\"color: blue\">ON <\/span>ses<span style=\"color: gray\">.<\/span>event_session_id <span style=\"color: gray\">= <\/span>sese<span style=\"color: gray\">.<\/span>event_session_id\r\n        <span style=\"color: gray\">JOIN <\/span><span style=\"color: green\">sys<\/span><span style=\"color: gray\">.<\/span><span style=\"color: green\">dm_xe_packages <\/span><span style=\"color: blue\">AS <\/span>p \r\n            <span style=\"color: blue\">ON <\/span>sese<span style=\"color: gray\">.<\/span>package <span style=\"color: gray\">= <\/span>p<span style=\"color: gray\">.<\/span>name\r\n        <span style=\"color: gray\">JOIN <\/span><span style=\"color: green\">sys<\/span><span style=\"color: gray\">.<\/span><span style=\"color: green\">dm_xe_object_columns <\/span><span style=\"color: blue\">AS <\/span>oc \r\n            <span style=\"color: blue\">ON <\/span>oc<span style=\"color: gray\">.<\/span><span style=\"color: magenta\">object_name <\/span><span style=\"color: gray\">= <\/span>sese<span style=\"color: gray\">.<\/span>name\r\n                <span style=\"color: gray\">AND <\/span>oc<span style=\"color: gray\">.<\/span>object_package_guid <span style=\"color: gray\">= <\/span>p<span style=\"color: gray\">.<\/span><span style=\"color: blue\">guid\r\n        <\/span><span style=\"color: gray\">JOIN <\/span>XETypeToSQLType <span style=\"color: blue\">AS <\/span>xetst\r\n            <span style=\"color: blue\">ON <\/span>oc<span style=\"color: gray\">.<\/span><span style=\"color: magenta\">type_name <\/span><span style=\"color: gray\">= <\/span>xetst<span style=\"color: gray\">.<\/span>XETypeName\r\n        <span style=\"color: blue\">WHERE <\/span>oc<span style=\"color: gray\">.<\/span>column_type <span style=\"color: gray\">= <\/span><span style=\"color: red\">'data'\r\n    <\/span><span style=\"color: blue\">UNION\r\n        SELECT \r\n            <\/span>ses<span style=\"color: gray\">.<\/span>name<span style=\"color: gray\">,\r\n            <\/span>sese<span style=\"color: gray\">.<\/span>name<span style=\"color: gray\">,\r\n            <\/span>sesa<span style=\"color: gray\">.<\/span>event_id<span style=\"color: gray\">,\r\n            <\/span>999 <span style=\"color: blue\">AS <\/span>column_id<span style=\"color: gray\">,\r\n            <\/span>sesa<span style=\"color: gray\">.<\/span>name<span style=\"color: gray\">,\r\n            <\/span><span style=\"color: red\">'action'<\/span><span style=\"color: gray\">,\r\n            <\/span>xetst<span style=\"color: gray\">.<\/span>SQLTypeName<span style=\"color: gray\">,\r\n            <\/span>xetst<span style=\"color: gray\">.<\/span>XMLLocation<span style=\"color: gray\">,\r\n            <\/span>xetst<span style=\"color: gray\">.<\/span>TypePrecidence\r\n        <span style=\"color: blue\">FROM <\/span><span style=\"color: green\">sys<\/span><span style=\"color: gray\">.<\/span><span style=\"color: green\">server_event_sessions <\/span><span style=\"color: blue\">AS <\/span>ses\r\n        <span style=\"color: gray\">JOIN <\/span><span style=\"color: green\">sys<\/span><span style=\"color: gray\">.<\/span><span style=\"color: green\">server_event_session_events <\/span><span style=\"color: blue\">AS <\/span>sese\r\n            <span style=\"color: blue\">ON <\/span>ses<span style=\"color: gray\">.<\/span>event_session_id <span style=\"color: gray\">= <\/span>sese<span style=\"color: gray\">.<\/span>event_session_id\r\n        <span style=\"color: gray\">JOIN <\/span><span style=\"color: green\">sys<\/span><span style=\"color: gray\">.<\/span><span style=\"color: green\">server_event_session_actions <\/span><span style=\"color: blue\">AS <\/span>sesa\r\n            <span style=\"color: blue\">ON <\/span>ses<span style=\"color: gray\">.<\/span>event_session_id <span style=\"color: gray\">= <\/span>sesa<span style=\"color: gray\">.<\/span>event_session_id\r\n                <span style=\"color: gray\">AND <\/span>sesa<span style=\"color: gray\">.<\/span>event_id <span style=\"color: gray\">= <\/span>sese<span style=\"color: gray\">.<\/span>event_id\r\n        <span style=\"color: gray\">JOIN <\/span><span style=\"color: green\">sys<\/span><span style=\"color: gray\">.<\/span><span style=\"color: green\">dm_xe_packages <\/span><span style=\"color: blue\">AS <\/span>p\r\n            <span style=\"color: blue\">ON <\/span>sesa<span style=\"color: gray\">.<\/span>package <span style=\"color: gray\">= <\/span>p<span style=\"color: gray\">.<\/span>name\r\n        <span style=\"color: gray\">JOIN <\/span><span style=\"color: green\">sys<\/span><span style=\"color: gray\">.<\/span><span style=\"color: green\">dm_xe_objects <\/span><span style=\"color: blue\">AS <\/span>o\r\n            <span style=\"color: blue\">ON <\/span>p<span style=\"color: gray\">.<\/span><span style=\"color: blue\">guid <\/span><span style=\"color: gray\">= <\/span>o<span style=\"color: gray\">.<\/span>package_guid\r\n                <span style=\"color: gray\">AND <\/span>sesa<span style=\"color: gray\">.<\/span>name <span style=\"color: gray\">= <\/span>o<span style=\"color: gray\">.<\/span>name\r\n        <span style=\"color: gray\">JOIN <\/span>XETypeToSQLType <span style=\"color: blue\">AS <\/span>xetst\r\n            <span style=\"color: blue\">ON <\/span>o<span style=\"color: gray\">.<\/span><span style=\"color: magenta\">type_name <\/span><span style=\"color: gray\">= <\/span>xetst<span style=\"color: gray\">.<\/span>XETypeName\r\n        <span style=\"color: blue\">WHERE <\/span>o<span style=\"color: gray\">.<\/span>object_type <span style=\"color: gray\">= <\/span><span style=\"color: red\">'action'\r\n<\/span><span style=\"color: blue\">GO<\/span><\/pre>\n<\/blockquote>\n<p>We can then create a Server Level DDL Trigger for the DDL_EVENT_SESSION_EVENTS group that will log the DDL operation to the XEvents_DDLOperations table, and at the same time populate the output information in the XEvents_SessionOutputs table when an Event Session is created, add any new outputs when an Event Session is altered, and delete the Event Session information when an Event Session is dropped.&#160; By adding new outputs when a Event Session is altered, we maintain a record of the original outputs, even if the Event was dropped from the Event Session.<\/p>\n<blockquote>\n<pre class=\"code\"><span style=\"color: blue\">CREATE TRIGGER <\/span>XEvents_DDLTrigger\r\n<span style=\"color: blue\">ON <\/span><span style=\"color: gray\">ALL <\/span><span style=\"color: blue\">SERVER \r\nFOR <\/span>DDL_EVENT_SESSION_EVENTS\r\n<span style=\"color: blue\">AS\r\nBEGIN\r\n    SET NOCOUNT ON<\/span><span style=\"color: gray\">;\r\n    <\/span><span style=\"color: blue\">DECLARE <\/span>@EventData <span style=\"color: blue\">XML <\/span><span style=\"color: gray\">= <\/span><span style=\"color: magenta\">EVENTDATA<\/span><span style=\"color: gray\">();\r\n    <\/span><span style=\"color: blue\">INSERT INTO <\/span>sqladmin<span style=\"color: gray\">.<\/span>dbo<span style=\"color: gray\">.<\/span>XEvents_DDLOperations <span style=\"color: gray\">(<\/span>DDLEventData<span style=\"color: gray\">)\r\n    <\/span><span style=\"color: blue\">VALUES <\/span><span style=\"color: gray\">(<\/span>@EventData<span style=\"color: gray\">);\r\n\r\n    <\/span><span style=\"color: blue\">DECLARE <\/span>@EventType <span style=\"color: blue\">NVARCHAR<\/span><span style=\"color: gray\">(<\/span>256<span style=\"color: gray\">) = <\/span>@EventData<span style=\"color: gray\">.<\/span>value<span style=\"color: gray\">(<\/span><span style=\"color: red\">'(EVENT_INSTANCE\/EventType)[1]'<\/span><span style=\"color: gray\">, <\/span><span style=\"color: red\">'nvarchar(256)'<\/span><span style=\"color: gray\">)\r\n    <\/span><span style=\"color: blue\">DECLARE <\/span>@SessionName <span style=\"color: blue\">NVARCHAR<\/span><span style=\"color: gray\">(<\/span>256<span style=\"color: gray\">) = <\/span>@EventData<span style=\"color: gray\">.<\/span>value<span style=\"color: gray\">(<\/span><span style=\"color: red\">'(EVENT_INSTANCE\/ObjectName)[1]'<\/span><span style=\"color: gray\">, <\/span><span style=\"color: red\">'nvarchar(256)'<\/span><span style=\"color: gray\">)\r\n\r\n    <\/span><span style=\"color: blue\">IF <\/span>@EventType <span style=\"color: gray\">= <\/span><span style=\"color: red\">'CREATE_EVENT_SESSION'\r\n    <\/span><span style=\"color: blue\">BEGIN\r\n        INSERT INTO <\/span>sqladmin<span style=\"color: gray\">.<\/span>dbo<span style=\"color: gray\">.<\/span>XEvents_SessionOutputs \r\n            <span style=\"color: gray\">(<\/span>EventSessionName<span style=\"color: gray\">, <\/span>EventName<span style=\"color: gray\">, <\/span>EventID<span style=\"color: gray\">, <\/span>ColumnID<span style=\"color: gray\">, <\/span>ColumnName<span style=\"color: gray\">, <\/span>NodeType<span style=\"color: gray\">,\r\n             <\/span>DataType<span style=\"color: gray\">, <\/span>XMLLocation<span style=\"color: gray\">, <\/span>TypePrecidence<span style=\"color: gray\">)\r\n        <\/span><span style=\"color: blue\">SELECT <\/span>EventSessionName<span style=\"color: gray\">, <\/span>EventName<span style=\"color: gray\">, <\/span>EventID<span style=\"color: gray\">, <\/span>ColumnID<span style=\"color: gray\">, <\/span>ColumnName<span style=\"color: gray\">, <\/span>NodeType<span style=\"color: gray\">,\r\n             <\/span>DataType<span style=\"color: gray\">, <\/span>XMLLocation<span style=\"color: gray\">, <\/span>TypePrecidence\r\n        <span style=\"color: blue\">FROM <\/span>sqladmin<span style=\"color: gray\">.<\/span>dbo<span style=\"color: gray\">.<\/span>XESession_OutputsFromDMVs\r\n        <span style=\"color: blue\">WHERE <\/span>EventSessionName <span style=\"color: gray\">= <\/span>@SessionName\r\n    <span style=\"color: blue\">END\r\n\r\n    IF <\/span>@EventType <span style=\"color: gray\">= <\/span><span style=\"color: red\">'ALTER_EVENT_SESSION'\r\n    <\/span><span style=\"color: blue\">BEGIN\r\n        <\/span><span style=\"color: green\">-- Add any new outputs to the Table\r\n        <\/span><span style=\"color: blue\">INSERT INTO <\/span>sqladmin<span style=\"color: gray\">.<\/span>dbo<span style=\"color: gray\">.<\/span>XEvents_SessionOutputs\r\n            <span style=\"color: gray\">(<\/span>EventSessionName<span style=\"color: gray\">, <\/span>EventName<span style=\"color: gray\">, <\/span>EventID<span style=\"color: gray\">, <\/span>ColumnID<span style=\"color: gray\">, <\/span>ColumnName<span style=\"color: gray\">, <\/span>NodeType<span style=\"color: gray\">,\r\n             <\/span>DataType<span style=\"color: gray\">, <\/span>XMLLocation<span style=\"color: gray\">, <\/span>TypePrecidence<span style=\"color: gray\">)\r\n        <\/span><span style=\"color: blue\">SELECT <\/span>vdmv<span style=\"color: gray\">.<\/span>EventSessionName<span style=\"color: gray\">, <\/span>vdmv<span style=\"color: gray\">.<\/span>EventName<span style=\"color: gray\">, <\/span>vdmv<span style=\"color: gray\">.<\/span>EventID<span style=\"color: gray\">, <\/span>vdmv<span style=\"color: gray\">.<\/span>ColumnID<span style=\"color: gray\">, <\/span>vdmv<span style=\"color: gray\">.<\/span>ColumnName<span style=\"color: gray\">, <\/span>vdmv<span style=\"color: gray\">.<\/span>NodeType<span style=\"color: gray\">,\r\n             <\/span>vdmv<span style=\"color: gray\">.<\/span>DataType<span style=\"color: gray\">, <\/span>vdmv<span style=\"color: gray\">.<\/span>XMLLocation<span style=\"color: gray\">, <\/span>vdmv<span style=\"color: gray\">.<\/span>TypePrecidence\r\n        <span style=\"color: blue\">FROM <\/span>sqladmin<span style=\"color: gray\">.<\/span>dbo<span style=\"color: gray\">.<\/span>XESession_OutputsFromDMVs vdmv\r\n        <span style=\"color: gray\">LEFT JOIN <\/span>sqladmin<span style=\"color: gray\">.<\/span>dbo<span style=\"color: gray\">.<\/span>XEvents_SessionOutputs xeso\r\n            <span style=\"color: blue\">ON <\/span>vdmv<span style=\"color: gray\">.<\/span>EventSessionName <span style=\"color: gray\">= <\/span>xeso<span style=\"color: gray\">.<\/span>EventSessionName\r\n                <span style=\"color: gray\">AND <\/span>vdmv<span style=\"color: gray\">.<\/span>EventName <span style=\"color: gray\">= <\/span>xeso<span style=\"color: gray\">.<\/span>EventName\r\n                <span style=\"color: gray\">AND <\/span>vdmv<span style=\"color: gray\">.<\/span>ColumnName <span style=\"color: gray\">= <\/span>vdmv<span style=\"color: gray\">.<\/span>ColumnName\r\n        <span style=\"color: blue\">WHERE <\/span>vdmv<span style=\"color: gray\">.<\/span>EventSessionName <span style=\"color: gray\">= <\/span>@SessionName\r\n          <span style=\"color: gray\">AND <\/span>xeso<span style=\"color: gray\">.<\/span>EventSessionName <span style=\"color: gray\">IS NULL\r\n    <\/span><span style=\"color: blue\">END\r\n\r\n    IF <\/span>@EventType <span style=\"color: gray\">= <\/span><span style=\"color: red\">'DROP_EVENT_SESSION'\r\n    <\/span><span style=\"color: blue\">BEGIN\r\n        <\/span><span style=\"color: green\">-- Delete the Output data for the Event Session\r\n        <\/span><span style=\"color: blue\">DELETE <\/span>sqladmin<span style=\"color: gray\">.<\/span>dbo<span style=\"color: gray\">.<\/span>XEvents_SessionOutputs\r\n        <span style=\"color: blue\">WHERE <\/span>EventSessionName <span style=\"color: gray\">= <\/span>@SessionName\r\n    <span style=\"color: blue\">END\r\nEND\r\nGO\r\n<\/span><\/pre>\n<\/blockquote>\n<p>If we recreate the TrackResourceWaits Event Session from yesterday\u2019s post and then query the XEvents_SessionOutputs table, we can see the outputs that we can expect from that Event Session:<\/p>\n<blockquote>\n<pre class=\"code\"><span style=\"color: blue\">SELECT <\/span><span style=\"color: gray\">*\r\n<\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: teal\">sqladmin<\/span><span style=\"color: gray\">.<\/span><span style=\"color: teal\">dbo<\/span><span style=\"color: gray\">.<\/span><span style=\"color: teal\">XEvents_SessionOutputs\r\n<\/span><span style=\"color: blue\">WHERE <\/span><span style=\"color: teal\">EventSessionName <\/span><span style=\"color: gray\">= <\/span><span style=\"color: red\">'TrackResourceWaits'\r\n\r\n<\/span><\/pre>\n<\/blockquote>\n<blockquote>\n<p><a href=\"https:\/\/www.SQLskills.com\/blogs\/jonathan\/wp-content\/uploads\/windowslivewriter\/anxeventaday31of31eventsessionddlevents\/02c02da4\/image.png\" target=\"_blank\"><img fetchpriority=\"high\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/www.SQLskills.com\/blogs\/jonathan\/wp-content\/uploads\/windowslivewriter\/anxeventaday31of31eventsessionddlevents\/1a77650a\/image_thumb.png\" width=\"644\" height=\"195\" \/><\/a> <\/p>\n<\/blockquote>\n<p>Using this information, we can also write a query to generate our XQuery statements for each of the outputs, as well as a column definition stub if we wanted to create a table to hold this information for analysis.<\/p>\n<blockquote>\n<pre class=\"code\"><span style=\"color: blue\">SELECT \r\n    <\/span><span style=\"color: red\">'event_data.value(''(event\/'<\/span><span style=\"color: gray\">+<\/span><span style=\"color: teal\">NodeType<\/span><span style=\"color: gray\">+<\/span><span style=\"color: red\">'[@name=&quot;'<\/span><span style=\"color: gray\">+<\/span><span style=\"color: teal\">ColumnName<\/span><span style=\"color: gray\">+<\/span><span style=\"color: red\">'&quot;]\/'<\/span><span style=\"color: gray\">+<\/span><span style=\"color: teal\">XMLLocation<\/span><span style=\"color: gray\">+<\/span><span style=\"color: red\">')[1]'', '''<\/span><span style=\"color: gray\">+<\/span><span style=\"color: teal\">DataType<\/span><span style=\"color: gray\">+<\/span><span style=\"color: red\">''') AS '<\/span><span style=\"color: gray\">+<\/span><span style=\"color: magenta\">QUOTENAME<\/span><span style=\"color: gray\">(<\/span><span style=\"color: teal\">ColumnName<\/span><span style=\"color: gray\">)+<\/span><span style=\"color: red\">',' <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: teal\">XQuery<\/span><span style=\"color: gray\">,\r\n    <\/span><span style=\"color: magenta\">QUOTENAME<\/span><span style=\"color: gray\">(<\/span><span style=\"color: teal\">ColumnName<\/span><span style=\"color: gray\">)+<\/span><span style=\"color: red\">' '<\/span><span style=\"color: gray\">+<\/span><span style=\"color: teal\">DataType<\/span><span style=\"color: gray\">+<\/span><span style=\"color: red\">', ' <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: teal\">ColumnDefinition\r\n<\/span><span style=\"color: blue\">FROM\r\n<\/span><span style=\"color: gray\">(\r\n    <\/span><span style=\"color: blue\">SELECT \r\n        <\/span><span style=\"color: magenta\">ROW_NUMBER<\/span><span style=\"color: gray\">() <\/span><span style=\"color: blue\">OVER <\/span><span style=\"color: gray\">(<\/span><span style=\"color: blue\">PARTITION BY <\/span><span style=\"color: teal\">ColumnName <\/span><span style=\"color: blue\">ORDER BY <\/span><span style=\"color: teal\">TypePrecidence <\/span><span style=\"color: blue\">DESC<\/span><span style=\"color: gray\">) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: teal\">partitionid<\/span><span style=\"color: gray\">,\r\n        <\/span><span style=\"color: teal\">EventSessionName<\/span><span style=\"color: gray\">,\r\n        <\/span><span style=\"color: teal\">EventID<\/span><span style=\"color: gray\">,\r\n        <\/span><span style=\"color: teal\">ColumnID<\/span><span style=\"color: gray\">,\r\n        <\/span><span style=\"color: teal\">ColumnName<\/span><span style=\"color: gray\">,\r\n        <\/span><span style=\"color: teal\">NodeType<\/span><span style=\"color: gray\">,\r\n        <\/span><span style=\"color: teal\">DataType<\/span><span style=\"color: gray\">,\r\n        <\/span><span style=\"color: teal\">XMLLocation\r\n    <\/span><span style=\"color: blue\">FROM <\/span><span style=\"color: teal\">sqladmin<\/span><span style=\"color: gray\">.<\/span><span style=\"color: teal\">dbo<\/span><span style=\"color: gray\">.<\/span><span style=\"color: teal\">XEvents_SessionOutputs\r\n<\/span><span style=\"color: gray\">) <\/span><span style=\"color: blue\">AS <\/span><span style=\"color: teal\">tab\r\n<\/span><span style=\"color: blue\">WHERE <\/span><span style=\"color: teal\">EventSessionName <\/span><span style=\"color: gray\">= <\/span><span style=\"color: red\">'TrackResourceWaits'\r\n  <\/span><span style=\"color: gray\">AND <\/span><span style=\"color: teal\">partitionid <\/span><span style=\"color: gray\">= <\/span>1\r\n<span style=\"color: blue\">ORDER BY <\/span><span style=\"color: teal\">EventID<\/span><span style=\"color: gray\">, <\/span><span style=\"color: teal\">ColumnID<\/span><\/pre>\n<\/blockquote>\n<blockquote>\n<p><a href=\"https:\/\/www.SQLskills.com\/blogs\/jonathan\/wp-content\/uploads\/windowslivewriter\/anxeventaday31of31eventsessionddlevents\/601bef28\/image.png\" target=\"_blank\"><img decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/www.SQLskills.com\/blogs\/jonathan\/wp-content\/uploads\/windowslivewriter\/anxeventaday31of31eventsessionddlevents\/71201d0b\/image_thumb.png\" width=\"644\" height=\"215\" \/><\/a> <\/p>\n<\/blockquote>\n<p>The information in the XQuery column can be copied and pasted into our TSQL Script for parsing the Event Data from the ring_buffer, pair_matching, or asynchronous_file_target Targets.&#160; You could also use this as the basis for writing your own Extended Events Target Data code generator, similar to <a href=\"http:\/\/sqlblog.com\/blogs\/adam_machanic\/archive\/2010\/05\/08\/extended-events-code-generator-v1-001-a-quick-fix.aspx\" target=\"_blank\">the one that Adam Machanic<\/a> created a year ago.<\/p>\n<p>That\u2019s it for this months series on Extended Events.&#160; You can find links to all of the posts on the round up post from December 1, <a href=\"https:\/\/www.sqlskills.com\/blogs\/jonathan\/post\/an-xevent-a-day-31-days-of-extended-events.aspx\" target=\"_blank\">An XEvent A Day: 31 days of Extended Events<\/a>.&#160; Hopefully its been informative, and you now have a better understanding of how Extended Events can be used inside of SQL Server 2008, 2008R2, and in Denali CTP1.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To close out this month\u2019s series on Extended Events we\u2019ll look at the DDL Events for the Event Session DDL operations, and how those can be used to track changes to Event Sessions and determine all of the possible outputs that could exist from an Extended Event Session.&#160; One of my least favorite quirks about [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,38,45],"tags":[],"class_list":["post-533","post","type-post","status-publish","format-standard","hentry","category-extended-events","category-sql-server-2008","category-xevent-a-day-series"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>An XEvent a Day (31 of 31) - Event Session DDL Events - Jonathan Kehayias<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlskills.com\/blogs\/jonathan\/an-xevent-a-day-31-of-31-event-session-ddl-events\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"An XEvent a Day (31 of 31) - Event Session DDL Events - Jonathan Kehayias\" \/>\n<meta property=\"og:description\" content=\"To close out this month\u2019s series on Extended Events we\u2019ll look at the DDL Events for the Event Session DDL operations, and how those can be used to track changes to Event Sessions and determine all of the possible outputs that could exist from an Extended Event Session.&#160; One of my least favorite quirks about [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/jonathan\/an-xevent-a-day-31-of-31-event-session-ddl-events\/\" \/>\n<meta property=\"og:site_name\" content=\"Jonathan Kehayias\" \/>\n<meta property=\"article:published_time\" content=\"2010-12-31T21:42:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-04-13T16:55:28+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.SQLskills.com\/blogs\/jonathan\/wp-content\/uploads\/windowslivewriter\/anxeventaday31of31eventsessionddlevents\/43627a13\/image_thumb.png\" \/>\n<meta name=\"author\" content=\"Jonathan Kehayias\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jonathan Kehayias\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/an-xevent-a-day-31-of-31-event-session-ddl-events\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/an-xevent-a-day-31-of-31-event-session-ddl-events\\\/\"},\"author\":{\"name\":\"Jonathan Kehayias\",\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/#\\\/schema\\\/person\\\/01c10d94f3648654ef706d5e6305f69c\"},\"headline\":\"An XEvent a Day (31 of 31) &#8211; Event Session DDL Events\",\"datePublished\":\"2010-12-31T21:42:00+00:00\",\"dateModified\":\"2017-04-13T16:55:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/an-xevent-a-day-31-of-31-event-session-ddl-events\\\/\"},\"wordCount\":1047,\"commentCount\":1,\"image\":{\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/an-xevent-a-day-31-of-31-event-session-ddl-events\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.SQLskills.com\\\/blogs\\\/jonathan\\\/wp-content\\\/uploads\\\/windowslivewriter\\\/anxeventaday31of31eventsessionddlevents\\\/43627a13\\\/image_thumb.png\",\"articleSection\":[\"Extended Events\",\"SQL Server 2008\",\"XEvent a Day Series\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/an-xevent-a-day-31-of-31-event-session-ddl-events\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/an-xevent-a-day-31-of-31-event-session-ddl-events\\\/\",\"url\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/an-xevent-a-day-31-of-31-event-session-ddl-events\\\/\",\"name\":\"An XEvent a Day (31 of 31) - Event Session DDL Events - Jonathan Kehayias\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/an-xevent-a-day-31-of-31-event-session-ddl-events\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/an-xevent-a-day-31-of-31-event-session-ddl-events\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.SQLskills.com\\\/blogs\\\/jonathan\\\/wp-content\\\/uploads\\\/windowslivewriter\\\/anxeventaday31of31eventsessionddlevents\\\/43627a13\\\/image_thumb.png\",\"datePublished\":\"2010-12-31T21:42:00+00:00\",\"dateModified\":\"2017-04-13T16:55:28+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/#\\\/schema\\\/person\\\/01c10d94f3648654ef706d5e6305f69c\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/an-xevent-a-day-31-of-31-event-session-ddl-events\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/an-xevent-a-day-31-of-31-event-session-ddl-events\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/an-xevent-a-day-31-of-31-event-session-ddl-events\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.SQLskills.com\\\/blogs\\\/jonathan\\\/wp-content\\\/uploads\\\/windowslivewriter\\\/anxeventaday31of31eventsessionddlevents\\\/43627a13\\\/image_thumb.png\",\"contentUrl\":\"https:\\\/\\\/www.SQLskills.com\\\/blogs\\\/jonathan\\\/wp-content\\\/uploads\\\/windowslivewriter\\\/anxeventaday31of31eventsessionddlevents\\\/43627a13\\\/image_thumb.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/an-xevent-a-day-31-of-31-event-session-ddl-events\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Extended Events\",\"item\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/category\\\/extended-events\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"An XEvent a Day (31 of 31) &#8211; Event Session DDL Events\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/#website\",\"url\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/\",\"name\":\"Jonathan Kehayias - The Rambling DBA\",\"description\":\"The Rambling DBA\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.sqlskills.com\\\/blogs\\\/jonathan\\\/#\\\/schema\\\/person\\\/01c10d94f3648654ef706d5e6305f69c\",\"name\":\"Jonathan Kehayias\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/86630e27f5deecc5c393ea57fc7c3b6a068949f4fd6b5309f81de5a276f12855?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/86630e27f5deecc5c393ea57fc7c3b6a068949f4fd6b5309f81de5a276f12855?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/86630e27f5deecc5c393ea57fc7c3b6a068949f4fd6b5309f81de5a276f12855?s=96&d=mm&r=g\",\"caption\":\"Jonathan Kehayias\"},\"sameAs\":[\"http:\\\/\\\/3.209.169.194\\\/blogs\\\/jonathan\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"An XEvent a Day (31 of 31) - Event Session DDL Events - Jonathan Kehayias","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/an-xevent-a-day-31-of-31-event-session-ddl-events\/","og_locale":"en_US","og_type":"article","og_title":"An XEvent a Day (31 of 31) - Event Session DDL Events - Jonathan Kehayias","og_description":"To close out this month\u2019s series on Extended Events we\u2019ll look at the DDL Events for the Event Session DDL operations, and how those can be used to track changes to Event Sessions and determine all of the possible outputs that could exist from an Extended Event Session.&#160; One of my least favorite quirks about [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/an-xevent-a-day-31-of-31-event-session-ddl-events\/","og_site_name":"Jonathan Kehayias","article_published_time":"2010-12-31T21:42:00+00:00","article_modified_time":"2017-04-13T16:55:28+00:00","og_image":[{"url":"https:\/\/www.SQLskills.com\/blogs\/jonathan\/wp-content\/uploads\/windowslivewriter\/anxeventaday31of31eventsessionddlevents\/43627a13\/image_thumb.png","type":"","width":"","height":""}],"author":"Jonathan Kehayias","twitter_misc":{"Written by":"Jonathan Kehayias","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/an-xevent-a-day-31-of-31-event-session-ddl-events\/#article","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/an-xevent-a-day-31-of-31-event-session-ddl-events\/"},"author":{"name":"Jonathan Kehayias","@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/#\/schema\/person\/01c10d94f3648654ef706d5e6305f69c"},"headline":"An XEvent a Day (31 of 31) &#8211; Event Session DDL Events","datePublished":"2010-12-31T21:42:00+00:00","dateModified":"2017-04-13T16:55:28+00:00","mainEntityOfPage":{"@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/an-xevent-a-day-31-of-31-event-session-ddl-events\/"},"wordCount":1047,"commentCount":1,"image":{"@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/an-xevent-a-day-31-of-31-event-session-ddl-events\/#primaryimage"},"thumbnailUrl":"https:\/\/www.SQLskills.com\/blogs\/jonathan\/wp-content\/uploads\/windowslivewriter\/anxeventaday31of31eventsessionddlevents\/43627a13\/image_thumb.png","articleSection":["Extended Events","SQL Server 2008","XEvent a Day Series"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.sqlskills.com\/blogs\/jonathan\/an-xevent-a-day-31-of-31-event-session-ddl-events\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/an-xevent-a-day-31-of-31-event-session-ddl-events\/","url":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/an-xevent-a-day-31-of-31-event-session-ddl-events\/","name":"An XEvent a Day (31 of 31) - Event Session DDL Events - Jonathan Kehayias","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/an-xevent-a-day-31-of-31-event-session-ddl-events\/#primaryimage"},"image":{"@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/an-xevent-a-day-31-of-31-event-session-ddl-events\/#primaryimage"},"thumbnailUrl":"https:\/\/www.SQLskills.com\/blogs\/jonathan\/wp-content\/uploads\/windowslivewriter\/anxeventaday31of31eventsessionddlevents\/43627a13\/image_thumb.png","datePublished":"2010-12-31T21:42:00+00:00","dateModified":"2017-04-13T16:55:28+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/#\/schema\/person\/01c10d94f3648654ef706d5e6305f69c"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/an-xevent-a-day-31-of-31-event-session-ddl-events\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/jonathan\/an-xevent-a-day-31-of-31-event-session-ddl-events\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/an-xevent-a-day-31-of-31-event-session-ddl-events\/#primaryimage","url":"https:\/\/www.SQLskills.com\/blogs\/jonathan\/wp-content\/uploads\/windowslivewriter\/anxeventaday31of31eventsessionddlevents\/43627a13\/image_thumb.png","contentUrl":"https:\/\/www.SQLskills.com\/blogs\/jonathan\/wp-content\/uploads\/windowslivewriter\/anxeventaday31of31eventsessionddlevents\/43627a13\/image_thumb.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/an-xevent-a-day-31-of-31-event-session-ddl-events\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/"},{"@type":"ListItem","position":2,"name":"Extended Events","item":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/category\/extended-events\/"},{"@type":"ListItem","position":3,"name":"An XEvent a Day (31 of 31) &#8211; Event Session DDL Events"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/","name":"Jonathan Kehayias - The Rambling DBA","description":"The Rambling DBA","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/#\/schema\/person\/01c10d94f3648654ef706d5e6305f69c","name":"Jonathan Kehayias","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/86630e27f5deecc5c393ea57fc7c3b6a068949f4fd6b5309f81de5a276f12855?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/86630e27f5deecc5c393ea57fc7c3b6a068949f4fd6b5309f81de5a276f12855?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/86630e27f5deecc5c393ea57fc7c3b6a068949f4fd6b5309f81de5a276f12855?s=96&d=mm&r=g","caption":"Jonathan Kehayias"},"sameAs":["http:\/\/3.209.169.194\/blogs\/jonathan"]}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-json\/wp\/v2\/posts\/533","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-json\/wp\/v2\/comments?post=533"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-json\/wp\/v2\/posts\/533\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-json\/wp\/v2\/media?parent=533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-json\/wp\/v2\/categories?post=533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/jonathan\/wp-json\/wp\/v2\/tags?post=533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}