Running a Trace

We created a simple stored procedure called TraceTune_Start to capture the basic information this application needs in a trace.

The source code for the stored procedure is below. I'd suggest creating a dedicated database for scripts like this if you can. It could also be placed in the master database or in any user database. This stored procedure writes a trace file directory to the disk of the server bypassing Profiler. It also ignores all the sp_reset_connection statements that are generated when sessions are reused by connection pooling. It's called like this:

EXECUTE [dbo].[TraceTune_start] 
   @Directory
  ,@File
  ,@Minutes
  ,@IncludeTimeStamp
  ,@MaxFileSize

The parameters are:

If both @Minutes and @MaxFileSize are set the trace will stop when either condition is reached.