Wednesday, March 28, 2012

How to use xp_trace_generate_event

Hi
I have created a stored procedure that create a trace on SQL 7 and start
the trace. but this procedure is sending the trace to a file. I want to send
the output of trace to a table.
I am using xp_trace_setqueuedestination and specified the proper destination
table, but still I am not able to get the data in the table.
After some research I find out that I have to xp_trace_generate_event.
But I don't know how to use xp_trace_generate_event to generate the output
to a trace table.
Can someone help in doing this?
Or is there some undocumented stored procedure like sp_trace_getdata that
exist in SQL 2000.
Thanks in advance.
Pushkar
It's hard to say without seeing what you are specifying for
xp_trace_setqueuedestination but try to qualify the table
for the table parameter, e.g. 'YourDB..YourTable'
Make sure you are using 4 for the destination parameter.
-Sue
On Wed, 8 Jun 2005 16:01:48 +0530, "Pushkar"
<tiwaripushkar@.yahoo.co.in> wrote:

>Hi
>I have created a stored procedure that create a trace on SQL 7 and start
>the trace. but this procedure is sending the trace to a file. I want to send
>the output of trace to a table.
>I am using xp_trace_setqueuedestination and specified the proper destination
>table, but still I am not able to get the data in the table.
>After some research I find out that I have to xp_trace_generate_event.
>But I don't know how to use xp_trace_generate_event to generate the output
>to a trace table.
>Can someone help in doing this?
>Or is there some undocumented stored procedure like sp_trace_getdata that
>exist in SQL 2000.
>Thanks in advance.
>Pushkar
>
|||Hi
Below is the script I am using:
-- Create a Queue
declare @.rc int
declare @.QueueHandle int
exec @.rc = xp_trace_addnewqueue 1000, 5000, 95, 90, 67354401, @.QueueHandle
output
if (@.rc != 0) goto error
-- Set the events
-- SQL Server 2000 specific events will not be scripted
exec xp_trace_seteventclassrequired @.QueueHandle, 10, 1
exec xp_trace_seteventclassrequired @.QueueHandle, 12, 1
exec xp_trace_seteventclassrequired @.QueueHandle, 14, 1
exec xp_trace_seteventclassrequired @.QueueHandle, 15, 1
exec xp_trace_seteventclassrequired @.QueueHandle, 17, 1
-- Set the Filters
exec xp_trace_setappfilter @.QueueHandle, N'', N'SQL Profiler'
-- set the destinations
exec xp_trace_setqueuedestination @.QueueHandle, 4, 1,
N'sql-nt4',N'[master]..[Untitled - 1]'
-- save the definition in the registry
exec xp_trace_savequeuedefinition @.QueueHandle, N'Untitled - 1', 1
-- display queue handle for future references
select QueueHandle=@.QueueHandle
goto finish
error:
select ErrorCode=@.rc
finish:
go
Please suggest what changes in script should I do to get the trace result in
the table.
Thanks
Pushkar
"Sue Hoegemeier" <Sue_H@.nomail.please> wrote in message
news:t0pda1dnmf5raf844u5laj2ct4iaooktvm@.4ax.com... [vbcol=seagreen]
> It's hard to say without seeing what you are specifying for
> xp_trace_setqueuedestination but try to qualify the table
> for the table parameter, e.g. 'YourDB..YourTable'
> Make sure you are using 4 for the destination parameter.
> -Sue
> On Wed, 8 Jun 2005 16:01:48 +0530, "Pushkar"
> <tiwaripushkar@.yahoo.co.in> wrote:
send[vbcol=seagreen]
destination[vbcol=seagreen]
output
>

No comments:

Post a Comment