SQL Server – System Trace Functions

SQL Server provides the following system trace functions that are useful if you are working with trace.

  • fn_trace_getinfo
  • fn_trace_gettable
  • fn_trace_getfilterinfo
  • fn_trace_geteventinfo

fn_trace_getinfo

This function returns the information of a specified trace or all running traces.

Syntax

fn_trace_getinfo ( { trace_id | NULL | 0 | DEFAULT } )

Example

See all the Running Trace

SELECT * FROM fn_trace_getinfo(NULL)


fn_trace_gettable

This function export the Trace file data into Table.

Syntax

fn_trace_gettable ( ‘filename’, number_files )

Example

See the example here


fn_trace_getfilterinfo

This functions returns information about the filters applied to a specified trace.

Syntax

fn_trace_getfilterinfo ( trace_id )

Example

SELECT * FROM fn_trace_getfilterinfo(1)

Here 1 is Trace ID


fn_trace_geteventinfo

This functions returns information about an event of the running trace

Syntax

fn_trace_geteventinfo ( trace_id )

Example

SELECT * FROM fn_trace_geteventinfo(1)

Here 1 is Trace ID

Hope this post help to get all the required information  about Trace.