Hi,
I have been beating my head against the wall on this one, and am hoping
someone can point out what I am doing wrong here.
I am trying to set up a trace (using script) that will tracks all the
"RPC:Completed" events and give me some of the vital statistics like
TextData, StartTime, EndTime, Duration, Reads, Writes, CPU, etc. To make
sure I didn't screw this up, I first set the trace up in Profiler and
exported the trace definition (File->Export->Script Trace Definition->SQL
Server 2005) to a file. I have cut and paste the script I get at the end.
The problem I have is that when I open the trace output in Profiler, I don't
see the TextData column - instead, I see the BinaryData column. This appears
to be happening only when tracing the "RPC:Completed" event. In other words,
if I use the same script and replace EventID "10" with a "12" in the
sp_trace_setevent calls, the TextData column is included in the output file.
Has anyone seen the same behavior or is this just me? My environment is
SQL2005 64-bit, SP1 on Windows 2003 R2 (64-bit). Thanks in advance for your
help.
Anand
------ BEGIN SCRIPT ------
-- Create a Queue
declare @rc int
declare @TraceID int
declare @maxfilesize bigint
set @maxfilesize = 5
-- Please replace the text InsertFileNameHere, with an appropriate
-- filename prefixed by a path, e.g., c:\MyFolder\MyTrace. The .trc
extension
-- will be appended to the filename automatically. If you are writing from
-- remote server to local drive, please use UNC path and make sure server
has
-- write access to your network share
exec @rc = sp_trace_create @TraceID output, 0, N'InsertFileNameHere',
@maxfilesize, NULL
if (@rc != 0) goto error
-- Client side File and Table cannot be scripted
-- Set the events
declare @on bit
set @on = 1
exec sp_trace_setevent @TraceID, 10, 15, @on
exec sp_trace_setevent @TraceID, 10, 16, @on
exec sp_trace_setevent @TraceID, 10, 1, @on
exec sp_trace_setevent @TraceID, 10, 9, @on
exec sp_trace_setevent @TraceID, 10, 17, @on
exec sp_trace_setevent @TraceID, 10, 10, @on
exec sp_trace_setevent @TraceID, 10, 18, @on
exec sp_trace_setevent @TraceID, 10, 11, @on
exec sp_trace_setevent @TraceID, 10, 12, @on
exec sp_trace_setevent @TraceID, 10, 13, @on
exec sp_trace_setevent @TraceID, 10, 6, @on
exec sp_trace_setevent @TraceID, 10, 14, @on
-- Set the Filters
declare @intfilter int
declare @bigintfilter bigint
exec sp_trace_setfilter @TraceID, 10, 0, 7, N'SQL Server Profiler -
5dba9f9a-7e18-4f26-8fb2-c73b7ddc6687'
-- Set the trace status to start
exec sp_trace_setstatus @TraceID, 1
-- display trace id for future references
select TraceID=@TraceID
goto finish
error:
select ErrorCode=@rc
finish:
go
------ END SCRIPT ------
Andrew J. Kelly - 30 Jul 2008 16:20 GMT
Anand,
By default Profiler will not have the TextData column checked for the RPC
events since it can get that information from the binary data column which
is usually more efficient. To make things consistent I usually just include
the textdata column and exclude the binary (unless I need it for something
else) when I create the trace. So just add the following line to your trace
script and you should be fine:
exec sp_trace_setevent @TraceID, 10, 1, @on

Signature
Andrew J. Kelly SQL MVP
Solid Quality Mentors
> Hi,
>
[quoted text clipped - 78 lines]
>
> ------ END SCRIPT ------
Anand - 30 Jul 2008 17:07 GMT
Thanks for you reply Andrew. My problem is that I do have "exec
sp_trace_setevent @TraceID, 10, 1, @on" in my script. I do not have "exec
sp_trace_setevent @TraceID, 10, 2, @on". But I still don't get the TextData
column in the output, but instead see the BinaryData column. In other words,
no matter what I do, I simply cannot seem to get the TextData column in the
output when tracing EventID 10!
Anand
> Anand,
>
[quoted text clipped - 90 lines]
>>
>> ------ END SCRIPT ------
Andrew J. Kelly - 30 Jul 2008 18:23 GMT
I am a little confused by what you mean by "output". Do you mean the
textdata column does not show up in Profiler? If so did you ensure the
column is selected in the list after you load the trace file? What happens
when you select directly from the file?
SELECT * FROM fn_trace_gettable('c:\MyFolder\MyTrace.trc', DEFAULT)

Signature
Andrew J. Kelly SQL MVP
Solid Quality Mentors
> Thanks for you reply Andrew. My problem is that I do have "exec
> sp_trace_setevent @TraceID, 10, 1, @on" in my script. I do not have "exec
[quoted text clipped - 100 lines]
>>>
>>> ------ END SCRIPT ------
Anand - 31 Jul 2008 00:50 GMT
I meant the output generated by the trace (the .trc file). I did not open it
using the function - I was opening the .trc file using Profiler to see what
was logged.
Will let you know what I get if I read the "output" using the function :-)
Anand
> I am a little confused by what you mean by "output". Do you mean the
> textdata column does not show up in Profiler? If so did you ensure the
[quoted text clipped - 107 lines]
>>>>
>>>> ------ END SCRIPT ------
Anand - 31 Jul 2008 16:08 GMT
Hi Andrew,
When I read the .trc file using the fn_trace_gettable function, I DO see the
TextData column!! If I open the same file using Profiler, I don't see that
column. I guess this is some kind of feature in Profiler that I was not
aware of :-)
Thanks a lot for your help. I have what I need now, although I am still
confused as to why Profiler does not show that column.
Anand
> I meant the output generated by the trace (the .trc file). I did not open
> it using the function - I was opening the .trc file using Profiler to see
[quoted text clipped - 115 lines]
>>>>>
>>>>> ------ END SCRIPT ------
Andrew J. Kelly - 31 Jul 2008 19:09 GMT
I will ask again. Did you ensure that the TextData column is checked off as
one of the columns in Profiler in the first place? You can add or remove
any columns or events that you want and TextData is not one of the selected
columns by default for an RPC event.

Signature
Andrew J. Kelly SQL MVP
Solid Quality Mentors
> Hi Andrew,
>
[quoted text clipped - 128 lines]
>>>>>>
>>>>>> ------ END SCRIPT ------
Erland Sommarskog - 31 Jul 2008 23:07 GMT
> I will ask again. Did you ensure that the TextData column is checked off
> as one of the columns in Profiler in the first place? You can add or
> remove any columns or events that you want and TextData is not one of
> the selected columns by default for an RPC event.
Actually, I seem to recall having made the same observation as Anand.
If I have a server-side trace, and open it in Profiler, TextData is
missing for some RPC events, although it's returned by fn_trace_gettable.
It was a while since I ran into this, but it may be that if I include
BinaryData in the trace, this does not happen.

Signature
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx