Getting Started with Adobe After Effects - Part 6: Motion Blur
A collection of quick technology learning tips from what people around you learn every day

Start, stop and close a server side trace

Apr 14 2012 12:00AM by vanne040   

Today, while doing query or performance analysis, I wanted to start a profiler trace on the sql server in question. But since profiler generates network traffic I was looking for another approach. I learned that we can start the trace using system stored procedures. But I went a bit further and used a sql agent job to schedule the start of the trace. To monitor the performance of an instance of SQL Server, we can trace the SQL Server events by using a server-side trace.

To create the definition for the server-side trace, we use the sptracecreate system stored procedure. To start the trace, we use the sptracesetstatus system stored procedure.

exec sp_trace_setstatus @TraceID, 1

Now that trace has already started I had to stop it once I got the required information. In order to manually stop the server-side trace, we must locate the traceid trace event, stop the trace, and then delete the trace definition from the instance of SQL Server.

I followed these steps,

Run the below Transact-SQL statement in SSMS to retrieve the list of the running trace

SELECT * FROM ::fn_trace_getinfo(DEFAULT)

Got the traceid of the server-side trace that I had to stop and ran the following statement,

EXEC sp_trace_setstatus @traceid = <traceid> , @status = 0

where <traceid> is the traceid noted above

Finally executed the following Transact-SQL statement to close the trace and to delete the trace information.

EXEC sp_trace_setstatus @traceid = <traceid> , @status = 2

where <traceid> is the traceid noted above

After we start a server-side trace, the trace continues to run and generates output until we stop the trace.

Read More..   [32134 clicks]

Published under: SQL Server Tips ·  ·  ·  · 


vanne040
83 · 2% · 657
8
 
5
 
 
0
Incorrect
 
0
Interesting
 
0
Forgotten



Submit

1  Comments  

Your Comment


Sign Up or Login to post a comment.

"Start, stop and close a server side trace" rated 5 out of 5 by 8 readers
Start, stop and close a server side trace , 5.0 out of 5 based on 8 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]