Export (0) Print
Expand All
ABS
ALL
AND
ANY
AVG
bit
COS
COT
DAY
EXP
GO
IN
LEN
LOG
MAX
MIN
NOT
OR
PI
SET
SIN
STR
SUM
TAN
USE
VAR
Expand Minimize

fn_trace_gettable

SQL Server 2000

Returns trace file information in a table format. This system function provides a mechanism for querying trace data stored in a file (trace_filename.trc). fn_trace_gettable can be used in a SELECT...INTO statement to load the data in the file into a SQL Server table.

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
A. Use fn_trace_getttable to return a table that can be loaded into SQL Profiler

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)
B. Use fn_trace_gettable to return a table with an IDENTITY column that can be loaded into a SQL Server table

This example calls the function as part of a SELECT...INTO statement and returns a table with an IDENTITY column that can be loaded into a SQL Server table (temp_trc).

USE pubs
SELECT IDENTITY(int, 1, 1) AS RowNumber, * 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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft