Importing Extended Event files

06 Jun 2022 36169 views 0 minutes to read Contributors

Extended Events

SQL Server has the ability to catch all kind of 'events' into an Extended Event File (XEL). These files are readable with C# / Powershell / SQL functions.

Reading XEL files can be a lengthy task especially when you want to do analysis on the data.

SQL Read XEL Function

SQL Server provides  a function to read XEL files: sys.fn_xe_file_target_read_file ( path, mdpath, initial_file_name, initial_offset )

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

More info here:

C# / Powershell

The function is implemented in Microsoft SQL Server libraries that are invokable by C# or Powershell:



We have created a powershell solution that uses this library to reads XEL files and import them via BCP into a database table.

SQLTreeo AiM trial download

Report a Bug

In this article