Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 server side trace

Author  Topic 

Peace2007
Posting Yak Master

239 Posts

Posted - 2009-02-23 : 04:59:23
what's the difference between closing server side trace and stopping it?

heavymind
Posting Yak Master

115 Posts

Posted - 2009-02-23 : 05:42:59
Stopping and Closing Traces
When a trace is first created, it has the status of 0, stopped (or not yet started, in that case). A trace can be brought back to that state at any time, using sp_trace_setstatus. To set trace ID 2 to a status of stopped, the following Transact-SQL code is used:

Copy Code
EXEC sp_trace_setstatus 2, 0Aside from the obvious benefit of the trace no longer collecting data, there is another perk to doing this: Once the trace is in a stopped state, you can modify the event/column selections and filters using the appropriate stored procedures, without re-creating the trace. This can be extremely useful if you only need to make a minor adjustment.

If you are actually finished tracing and do not wish to continue at a later time, you can remove the trace definition from the system altogether by setting its status to 2:

Copy Code
EXEC sp_trace_setstatus 2, 2Note Trace definitions will be automatically removed in the case of a SQL Server service restart, so if you do need to run the same trace again later either save it as a Profiler template or save the script used to start it.


Thanks, Vadym
MCITP DBA 2005/2008
Chief DBA at http://www.db-staff.com
Go to Top of Page

Peace2007
Posting Yak Master

239 Posts

Posted - 2009-02-23 : 06:07:00
Thanks Vadym for the detailed description :)

I'm having another question: actually, I've started a server side trace yesterday and when I queried fn_trace_getinfo, it told me that it's run. The server has not been restarted and neither has been logged of but the trace is in stop status now! Can some other events stop the server side trace?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-02-23 : 06:13:57
If trace file gets full.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-23 : 07:19:22
Have you specified stop time in it?
Go to Top of Page

Peace2007
Posting Yak Master

239 Posts

Posted - 2009-02-23 : 08:11:59
When we create a trace via profiler, it creates another file when the first one is full. doesn't server side trace do that?

I'd specified an stop time but it stopped before that time!
Go to Top of Page

heavymind
Posting Yak Master

115 Posts

Posted - 2009-02-23 : 09:23:46
sp_trace_create has param
[ , [ @filecount = ] 'max_rollover_files' ]
which is optional and is apparently 1 by default. thus if you need more files to rollover - change this param

Thanks, Vadym
MCITP DBA 2005/2008
Chief DBA at http://www.db-staff.com
Go to Top of Page

heavymind
Posting Yak Master

115 Posts

Posted - 2009-02-23 : 09:25:09
parameter is valid only if the TRACE_FILE_ROLLOVER option is specified.
read thoroughly the topic
http://msdn.microsoft.com/en-us/library/ms190362.aspx


Thanks, Vadym
MCITP DBA 2005/2008
Chief DBA at http://www.db-staff.com
Go to Top of Page
   

- Advertisement -