Click to Rate and Give Feedback
MSDN
MSDN Library
SQL Server
SQL Server 2008
Database Engine
Technical Reference
 fn_trace_gettable (Transact-SQL)
Other versions are also available for the following:
SQL Server 2008 Books Online (August 2008)
fn_trace_gettable (Transact-SQL)

Returns the content of one or more trace files in tabular form.

Topic link icon Transact-SQL Syntax Conventions

fn_trace_gettable ( filename , number_files )
filename

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

number_files

Specifies the number of rollover files to be read. This number includes the initial file specified in filename. number_files is an int.

If number_files is specified as default, fn_trace_gettable reads all rollover files until it reaches the end of the trace. fn_trace_gettable returns a table with all the columns valid for the specified trace. For more information, see sp_trace_setevent (Transact-SQL).

This function can read a trace that is still active on the instance on which it is executed.

Requires ALTER TRACE permission on the server.

A. Using fn_trace_gettable to import rows from a trace file

The following example calls fn_trace_gettable inside the FROM clause of a SELECT...INTO statement.

USE AdventureWorks;
GO
SELECT * INTO temp_trc
FROM fn_trace_gettable('c:\temp\my_trace.trc', default);
GO

B. Using fn_trace_gettable to return a table with an IDENTITY column that can be loaded into a SQL Server table

The following example calls the function as part of a SELECT...INTO statement and returns a table with an IDENTITY column that can be loaded into the table temp_trc.

USE AdventureWorks;
GO
SELECT IDENTITY(int, 1, 1) AS RowNumber, * INTO temp_trc
FROM fn_trace_gettable('c:\temp\my_trace.trc', default);
GO
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker