View a Saved Trace (Transact-SQL)

APPLIES TO: yesSQL Server noAzure SQL Database noAzure SQL Data Warehouse noParallel Data Warehouse

This topic describes how to use built-in functions to view a saved trace.

To view a specific trace

  1. Execute fn_trace_getinfo by specifying the ID of the trace about which information is needed. This function returns a table that lists the trace, trace property, and information about the property.

We are listening: If you find something outdated or incorrect in this article, such as a step or a code example, please tell us. You can click the This page button in the Feedback section at the bottom of this page. We read every item of feedback about SQL, typically the next day. Thanks.

 Invoke the function this way:  

```  
SELECT *  
FROM ::fn_trace_getinfo(trace_id)  
```  

To view all existing traces

  1. Execute fn_trace_getinfo by specifying 0 or default. This function returns a table that lists all the traces, their properties, and information about these properties.

    Invoke the function as follows:

    SELECT *  
    FROM ::fn_trace_getinfo(default)  
    

.NET Framework Security

To run the built-in function fn_trace_getinfo, the user needs the following permission:

ALTER TRACE on the server.

See Also

sys.fn_trace_getinfo (Transact-SQL)
View and Analyze Traces with SQL Server Profiler