SYSTEM FUNCTION SYS.FN_TRACE_GETTABLE’S RESULT SET

To collect information about activities on SQL Server, SQL Profiler or server side trare is used. To start with profiler let’s set firts parameters as below.




“Trace name” is given as Test and “Save to file” parameter is set as D:\TraceFile.trc and “Maximum file size” as 50

As seen above, only  5 column information and 2 event information is collected.


Collected information is seen like this.
If we use T-SQL commad to read trace file by using “select * from sys.fn_trace_gettable('d:\TraceFile.trc',default)” command we see more columns then we collected but as nulls as seen below.


We change the column order, by using  “Trace Properties” window and add column “DatabaseID”.

With T-SQL command, the result set is the same order. And DatabaseID colum is not null as can be seen below. 



Conclusion:
With the trace function sys.fn_trace_gettable, we get always the same columns what ever columns we traced.   The colums we did not traced are null columns.

No comments:

Post a Comment