<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Search results matching tags 'Tools' and 'General'</title><link>http://sqlblog.com/search/SearchResults.aspx?o=DateDescending&amp;tag=Tools,General&amp;orTags=0</link><description>Search results matching tags 'Tools' and 'General'</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Whats in the default trace?</title><link>http://sqlblog.com/blogs/tibor_karaszi/archive/2007/03/12/whats-in-the-default-trace.aspx</link><pubDate>Mon, 12 Mar 2007 09:23:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:967</guid><dc:creator>TiborKaraszi</dc:creator><description>&lt;P&gt;As you probably know, there's a trace running by default in SQL Server 2005. The directory for the trace file is the SQL Server log directory, and you can turn off and on this trace with sp_configure. &lt;/P&gt;
&lt;P&gt;But how do we find out what events and columns are traced to this? We use a trace function and some trace catalog views:&lt;/P&gt;
&lt;P&gt;The function fn_trace_geteventinfo returns what columns and events are captured by a configured trace. But we don't want to see the column id and event id, we want the names. So we join this to the following functions:&lt;BR&gt;sys.trace_events&lt;BR&gt;sys.trace_categories&lt;BR&gt;sys.trace_columns&lt;/P&gt;
&lt;P&gt;Here's the end result:&lt;/P&gt;
&lt;P&gt;SELECT cat.name AS CategoryName, e.name AS EventName, c.name AS ColumnName &lt;BR&gt;FROM fn_trace_geteventinfo(1) AS rt&lt;BR&gt;&amp;nbsp;INNER JOIN sys.trace_events AS e&lt;BR&gt;&amp;nbsp;&amp;nbsp; ON rt.eventid = e.trace_event_id&lt;BR&gt;&amp;nbsp;INNER JOIN sys.trace_columns AS c&lt;BR&gt;&amp;nbsp;&amp;nbsp; ON rt.columnid = c.trace_column_id &lt;BR&gt;&amp;nbsp;INNER JOIN sys.trace_categories AS cat&lt;BR&gt;&amp;nbsp;&amp;nbsp; ON e.category_id = cat.category_id&lt;BR&gt;ORDER BY CategoryName, EventName, ColumnName&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;And here's one with only category and event:&lt;/P&gt;
&lt;P&gt;SELECT DISTINCT cat.name AS CategoryName, e.name AS EventName&lt;BR&gt;FROM fn_trace_geteventinfo(1) AS rt&lt;BR&gt;&amp;nbsp;INNER JOIN sys.trace_events AS e&lt;BR&gt;&amp;nbsp;&amp;nbsp; ON rt.eventid = e.trace_event_id&lt;BR&gt;&amp;nbsp;INNER JOIN sys.trace_categories AS cat&lt;BR&gt;&amp;nbsp;&amp;nbsp; ON e.category_id = cat.category_id&lt;BR&gt;ORDER BY CategoryName, EventName&lt;/P&gt;</description></item></channel></rss>