vrijdag 12 december 2008

Reading SQL Trace Files using fn_trace_gettable function

Reading SQL Trace Files using fn_trace_gettable function:
--------------------------------------------------------
http://kalpeshshirodker.wordpress.com/2008/02/15/reading-sql-trace-files-using-fn_trace_gettable-function/

Notes(Important):
----------------
1): Run SQL Profiler to record events you want to check.
2): Be sure that the result file will be saved to a disk with '.trc'.
3): after stop recording search in the result file by using the following query:

SELECT Count(*) as CountOfEvents,
AVG(Duration) AS AvgDuration,
SUM(Duration) AS [SumDuration],
SUBSTRING(TextData, 1, 30) AS [Text Data]
FROM ::fn_trace_gettable('C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\log_41.trc',default)
WHERE EventClass in (10,12) -- BatchCompleted, RPC Completed
GROUP BY SUBSTRING(TextData, 1, 30)
ORDER BY SUM(Duration) DESC

This will give a list with all queries runs on the database at the record time.

Geen opmerkingen:

Een reactie posten