Database Reference
In-Depth Information
You can see the events at the top of the window showing the type of event and the date and time of the event.
Clicking the event at the top will open the fields that were captured with the event on the bottom of the screen. As you
can see, all the information I've been talking about is available to you. Also, if you're unhappy with having a divided
output, you can right-click a column and select Show Column in Table from the context menu. This will move it up
into the top part of the screen, displaying all the information in a single location, as shown in Figure 6-8 .
Figure 6-8. The statement column has been added to the table
You can also open the files you've collected through this interface and use it to browse the data. You can search
within a column on the collected data, sort by them, and group by fields. One of the great ways to see an aggregate
of all calls to a particular query is to use query_hash, a global field that you can add to your data collection. The GUI
offers a lot of ways to manipulate the information you've collected.
Watching this information through the GUI and browsing through files is fine, but you're going to want to
automate the creation of these sessions. That's what the next section covers.
Extended Events Automation
The ability to use the GUI to build a session and define the events you want to capture does make things simple,
but, unfortunately, it's not a model that will scale. If you need to manage multiple servers where you're going to
create sessions for capturing key query performance metrics, you're not going to want to connect to each one and go
through the GUI to select the events, the output, and so on. This is especially true if you take into account the chance
of a mistake. Instead, it's much better to learn how to work with sessions directly from T-SQL. This will enable you to
build a session that can be run on a number of servers in your system. Even better, you're going to find that building
sessions directly is easier in some ways than using the GUI, and you're going to be much more knowledgeable about
how these processes work.
Creating a Session Script Using the GUI
You can create a scripted trace in one of two ways, manually or with the GUI. Until you get comfortable with all the
requirements of the scripts, the easy way is to use the Extended Events tool GUI. These are the steps you'll need
to perform:
1.
Define a session.
2.
Right-click the session, and select Script Sessions As, CREATE To, and File to output
straight to a file. Or, use the Script button at the top of the New Session window to create a
T-SQL command in the Query window.
 
Search WWH ::




Custom Search