fn_xe_file_target_read_file (Transact-SQL)

Reads files that are created by the Extended Events asynchronous file target. One event, in XML format, is returned per row.

Topic link iconTransact-SQL Syntax Conventions

Syntax

sys.fn_xe_file_target_read_file (path, mdpath, initial_file_name, initial_offset)

Arguments

  • path
    The path to the files to read. path can contain wildcards and include the name of a file. path is nvarchar(260). There is no default.

  • mdpath
    The path to the metadata file that corresponds to the file or files specified by the path argument. mdpath is nvarchar(260). There is no default.

  • initial_file_name
    The first file to read from path. initial_file_name is nvarchar(260). There is no default. If null is specified as the argument all the files found in path are read.

    Note

    initial_file_name and initial_offset are paired arguments. If you specify a value for either argument you must specify a value for the other argument.

  • initial_offset
    The offset in the first file where reading begins. initial_offset is bigint. If null is specified as the argument the entire file will be read.

Table Returned

Column name

Data type

Description

module_guid

uniqueidentifier

The event module GUID. Is not nullable.

package_guid

uniqueidentifier

The event package GUID. Is not nullable.

object_name

nvarchar(256)

The name of the event. Is not nullable.

event_data

nvarchar(max)

The event contents, in XML format. Is not nullable.

file_name

nvarchar(260)

The name of the file that contains the event. Is not nullable.

file_offset

bigint

The offset of the block in the file that contains the event. Is not nullable.

Permissions

Requires VIEW SERVER STATE permission on the server.

Examples

A. Retrieving data from file targets

The following example gets all the rows from all the files. In this example the file targets and metafiles are located in the trace folder on the C:\ drive.

select * from sys.fn_xe_file_target_read_file('C:\traces\*.xel', 'C:\traces\metafile.xem', null, null)