Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

SQL Server 2005 - Server side trace script

 
   Database Forums (Home) -> Tools RSS
Next:  SQL Management Studio and regional settings  
Author Message
Anand

External


Since: Jul 30, 2008
Posts: 4



(Msg. 1) Posted: Wed Jul 30, 2008 10:42 am
Post subject: SQL Server 2005 - Server side trace script
Archived from groups: microsoft>public>sqlserver>tools (more info?)

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 ------

 >> Stay informed about: SQL Server 2005 - Server side trace script 
Back to top
Login to vote
Andrew J. Kelly

External


Since: Sep 01, 2003
Posts: 975



(Msg. 2) Posted: Wed Jul 30, 2008 11:20 am
Post subject: Re: SQL Server 2005 - Server side trace script [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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

--
Andrew J. Kelly SQL MVP
Solid Quality Mentors


"Anand" wrote in message

> 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 ------

 >> Stay informed about: SQL Server 2005 - Server side trace script 
Back to top
Login to vote
Anand

External


Since: Jul 30, 2008
Posts: 4



(Msg. 3) Posted: Wed Jul 30, 2008 12:07 pm
Post subject: Re: SQL Server 2005 - Server side trace script [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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

"Andrew J. Kelly" wrote in message

> 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
>
> --
> Andrew J. Kelly SQL MVP
> Solid Quality Mentors
>
>
> "Anand" wrote in message
>
>> 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 ------
>
 >> Stay informed about: SQL Server 2005 - Server side trace script 
Back to top
Login to vote
Andrew J. Kelly

External


Since: Sep 01, 2003
Posts: 975



(Msg. 4) Posted: Wed Jul 30, 2008 1:23 pm
Post subject: Re: SQL Server 2005 - Server side trace script [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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)


--
Andrew J. Kelly SQL MVP
Solid Quality Mentors


"Anand" wrote in message

> 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
>
> "Andrew J. Kelly" wrote in message
>
>> 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
>>
>> --
>> Andrew J. Kelly SQL MVP
>> Solid Quality Mentors
>>
>>
>> "Anand" wrote in message
>>
>>> 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 ------
>>
 >> Stay informed about: SQL Server 2005 - Server side trace script 
Back to top
Login to vote
Anand

External


Since: Jul 30, 2008
Posts: 4



(Msg. 5) Posted: Wed Jul 30, 2008 7:50 pm
Post subject: Re: SQL Server 2005 - Server side trace script [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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 Smile

Anand

"Andrew J. Kelly" wrote in message
news:#7PB$jm8IHA.1568@TK2MSFTNGP04.phx.gbl...
> 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)
>
>
> --
> Andrew J. Kelly SQL MVP
> Solid Quality Mentors
>
>
> "Anand" wrote in message
>
>> 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
>>
>> "Andrew J. Kelly" wrote in message
>>
>>> 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
>>>
>>> --
>>> Andrew J. Kelly SQL MVP
>>> Solid Quality Mentors
>>>
>>>
>>> "Anand" wrote in message
>>>
>>>> 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 ------
>>>
>
 >> Stay informed about: SQL Server 2005 - Server side trace script 
Back to top
Login to vote
Anand

External


Since: Jul 30, 2008
Posts: 4



(Msg. 6) Posted: Thu Jul 31, 2008 11:08 am
Post subject: Re: SQL Server 2005 - Server side trace script [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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 Smile

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

"Anand" wrote in message

> 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 Smile
>
> Anand
>
> "Andrew J. Kelly" wrote in message
> news:#7PB$jm8IHA.1568@TK2MSFTNGP04.phx.gbl...
>> 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)
>>
>>
>> --
>> Andrew J. Kelly SQL MVP
>> Solid Quality Mentors
>>
>>
>> "Anand" wrote in message
>>
>>> 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
>>>
>>> "Andrew J. Kelly" wrote in message
>>>
>>>> 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
>>>>
>>>> --
>>>> Andrew J. Kelly SQL MVP
>>>> Solid Quality Mentors
>>>>
>>>>
>>>> "Anand" wrote in message
>>>>
>>>>> 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 ------
>>>>
>>
 >> Stay informed about: SQL Server 2005 - Server side trace script 
Back to top
Login to vote
Andrew J. Kelly

External


Since: Sep 01, 2003
Posts: 975



(Msg. 7) Posted: Thu Jul 31, 2008 2:09 pm
Post subject: Re: SQL Server 2005 - Server side trace script [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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.

--
Andrew J. Kelly SQL MVP
Solid Quality Mentors


"Anand" wrote in message

> 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 Smile
>
> 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
>
> "Anand" wrote in message
>
>> 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
>> Smile
>>
>> Anand
>>
>> "Andrew J. Kelly" wrote in message
>> news:#7PB$jm8IHA.1568@TK2MSFTNGP04.phx.gbl...
>>> 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)
>>>
>>>
>>> --
>>> Andrew J. Kelly SQL MVP
>>> Solid Quality Mentors
>>>
>>>
>>> "Anand" wrote in message
>>>
>>>> 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
>>>>
>>>> "Andrew J. Kelly" wrote in message
>>>>
>>>>> 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
>>>>>
>>>>> --
>>>>> Andrew J. Kelly SQL MVP
>>>>> Solid Quality Mentors
>>>>>
>>>>>
>>>>> "Anand" wrote in message
>>>>>
>>>>>> 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 ------
>>>>>
>>>
 >> Stay informed about: SQL Server 2005 - Server side trace script 
Back to top
Login to vote
Erland Sommarskog2

External


Since: May 30, 2004
Posts: 1649



(Msg. 8) Posted: Thu Jul 31, 2008 3:07 pm
Post subject: Re: SQL Server 2005 - Server side trace script [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Andrew J. Kelly (sqlmvpnooospam@shadhawk.com) writes:
> 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.

--
Erland Sommarskog, SQL Server MVP, esquel.RemoveThis@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
 >> Stay informed about: SQL Server 2005 - Server side trace script 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Limiting a server side trace to a specific table in SQL 2000 - I have setup a server side trace on a database, but now I want to limit the queries captured to a specific table. Is there a way to do this with the filters available? I have attempted to filter on the Object Name, but the SQL:BatchCompleted class..

SQL 2005 Show Server Trace -

Profiler - Trace SQL Server assignment problem - My development machine was built using an image from someone else's computer (thinking it would save me time). When I start a new trace, I can intially select (local) as the Trace SQL Server but it reverts to the instance name that the image was take...

SQL 2005 profiler : how to specify particular database in .. - In SQL 2005 profiler, how to specify particular database on the server box to trace?

Manage SQL Server 2005 while keeping SQL Server 2000 - I've got SQL Server 2000 running on my PC, and I want to continue doing so. But now I also need to manage a remote SQL Server 2005 database. I think that I need to install SQL Server Management Studio to do so. (Please correct me if that's wrong.) Can...
   Database Forums (Home) -> Tools All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]