Databases Reference
In-Depth Information
We deliberately kept the value of the FILEGROWTH attribute as
smaller as 1 MB in order to demonstrate this recipe. Setting value
of the FILEGROWTH attribute this small is just for the sake of being
able to produce the desired file growth events. Such small value for
the FILEGROWTH attribute is not recommended and should not be
used on production server with heavy DML operations.
Once the record insertion operation is completed, the script is executed to stop and close the
trace by again calling the stored procedure sp_trace_setstatus twice with the appropriate
status value for each call. Remember that to close a trace, it should be stopped first. So, a
trace should be stopped first before it can be closed.
After closing a trace, we make sure that the trace stopped and closed successfully by querying
sys.traces system catalog view again.
Once our trace is stopped, we use fn_trace_gettable() function to query the captured
trace data saved in specified trace file whose full file path is also being passed to the function
for the first parameter filename . We also pass the default value for the second parameter
number_files of the function which specifies that the function should read all rollover files
to return trace data. Because this function does not return any column for the event class'
name, we join it with sys.trace_events system catalog view on IDs of event classes in
order to fetch the names of event classes.
If you want to analyze large size of trace data containing large
number of trace files, then you should specify 1 for number_files
parameter. If you specify default, the SQL Server tries to load all
trace files into memory and then inserts them into a table in a single
operation, which may crash your system.
 
Search WWH ::




Custom Search