fn_trace_gettable

Transact-SQL Reference

Transact-SQL Reference

fn_trace_gettable

Returns trace file information in a table format.

Syntax

fn_trace_gettable( [ @filename = ] filename , [ @numfiles = ] number_files )

Arguments

[ @filename = ] filename

Specifies the initial trace to be read. filename is nvarchar(256), with no default.

[ @numfiles = ] number_files

Specifies the number of rollover files, including the initial file specified in filename, to be read. number_files is int. Users may specify the default value "default" to tell SQL Server to read all rollover files until the end of the trace.

SELECT * FROM ::fn_trace_gettable('c:\my_trace.trc', default)
GO

OR

SELECT * FROM ::fn_trace_gettable(('c:\my_trace.trc', -1)
GO
Tables Returned

fn_trace_gettable returns a table with all the valid columns. For information, see sp_trace_setevent.

Examples

This example calls the function as part of a SELECT..INTO statement and returns a table that can be loaded into SQL Profiler.

USE pubs
SELECT * INTO temp_trc
FROM ::fn_trace_gettable(c:\my_trace.trc", default)

See Also

sp_trace_generateevent

sp_trace_setevent

sp_trace_setfilter

sp_trace_setstatus