/*****************************************************************************
*   Presentation:  M09_Benchmarking and Baselining
*   FileName:  sp_custom_default_trace.sql
*
*   Summary: Demonstrates how to create a replacement for the Default Trace
*
*   Date: March 7, 2011 
*
*   SQL Server Versions:
*         2008, 2008 R2
*         
******************************************************************************
*   Copyright (C) 2011 Jonathan M. Kehayias, SQLskills.com
*   All rights reserved. 
*
*   For more scripts and sample code, check out 
*      http://sqlskills.com/blogs/jonathan
*
*   You may alter this code for your own *non-commercial* purposes. You may
*   republish altered code as long as you include this copyright and give 
*	due credit. 
*
*
*   THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF 
*   ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 
*   TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
*   PARTICULAR PURPOSE. 
*
******************************************************************************/

USE master
GO

CREATE PROCEDURE sp_custom_default_trace
AS

declare @rc int
declare @TraceID int
declare @maxfilesize bigint
declare @filecount int
declare @filedate char(8)
declare @filename nvarchar(128)
set @maxfilesize = 50 
set @filecount = 10
set @filedate = CONVERT ( char(8), getdate(), 112 )  + '_' +replace(CONVERT (char(18), getdate(), 108), ':', '')
set @filename = 'c:\SQLSkills\custom_default_trace-' + @filedate

exec @rc = sp_trace_create 
	@TraceID output, 
	@options = 2, 
	@tracefile = @filename, 
	@maxfilesize = @maxfilesize, 
	@filecount = @filecount
	
if (@rc != 0) goto error

-- Set the events
declare @on bit
set @on = 1
exec sp_trace_setevent @TraceID, 92, 7, @on
exec sp_trace_setevent @TraceID, 92, 15, @on
exec sp_trace_setevent @TraceID, 92, 8, @on
exec sp_trace_setevent @TraceID, 92, 12, @on
exec sp_trace_setevent @TraceID, 92, 36, @on
exec sp_trace_setevent @TraceID, 92, 60, @on
exec sp_trace_setevent @TraceID, 92, 64, @on
exec sp_trace_setevent @TraceID, 92, 9, @on
exec sp_trace_setevent @TraceID, 92, 13, @on
exec sp_trace_setevent @TraceID, 92, 25, @on
exec sp_trace_setevent @TraceID, 92, 41, @on
exec sp_trace_setevent @TraceID, 92, 10, @on
exec sp_trace_setevent @TraceID, 92, 14, @on
exec sp_trace_setevent @TraceID, 92, 26, @on
exec sp_trace_setevent @TraceID, 92, 3, @on
exec sp_trace_setevent @TraceID, 92, 11, @on
exec sp_trace_setevent @TraceID, 92, 35, @on
exec sp_trace_setevent @TraceID, 92, 51, @on
exec sp_trace_setevent @TraceID, 94, 7, @on
exec sp_trace_setevent @TraceID, 94, 15, @on
exec sp_trace_setevent @TraceID, 94, 8, @on
exec sp_trace_setevent @TraceID, 94, 12, @on
exec sp_trace_setevent @TraceID, 94, 36, @on
exec sp_trace_setevent @TraceID, 94, 60, @on
exec sp_trace_setevent @TraceID, 94, 64, @on
exec sp_trace_setevent @TraceID, 94, 9, @on
exec sp_trace_setevent @TraceID, 94, 13, @on
exec sp_trace_setevent @TraceID, 94, 25, @on
exec sp_trace_setevent @TraceID, 94, 41, @on
exec sp_trace_setevent @TraceID, 94, 10, @on
exec sp_trace_setevent @TraceID, 94, 14, @on
exec sp_trace_setevent @TraceID, 94, 26, @on
exec sp_trace_setevent @TraceID, 94, 3, @on
exec sp_trace_setevent @TraceID, 94, 11, @on
exec sp_trace_setevent @TraceID, 94, 35, @on
exec sp_trace_setevent @TraceID, 94, 51, @on
exec sp_trace_setevent @TraceID, 167, 3, @on
exec sp_trace_setevent @TraceID, 167, 35, @on
exec sp_trace_setevent @TraceID, 167, 51, @on
exec sp_trace_setevent @TraceID, 167, 4, @on
exec sp_trace_setevent @TraceID, 167, 12, @on
exec sp_trace_setevent @TraceID, 167, 60, @on
exec sp_trace_setevent @TraceID, 167, 64, @on
exec sp_trace_setevent @TraceID, 167, 1, @on
exec sp_trace_setevent @TraceID, 167, 25, @on
exec sp_trace_setevent @TraceID, 167, 41, @on
exec sp_trace_setevent @TraceID, 167, 49, @on
exec sp_trace_setevent @TraceID, 167, 14, @on
exec sp_trace_setevent @TraceID, 167, 26, @on
exec sp_trace_setevent @TraceID, 167, 30, @on
exec sp_trace_setevent @TraceID, 93, 7, @on
exec sp_trace_setevent @TraceID, 93, 15, @on
exec sp_trace_setevent @TraceID, 93, 8, @on
exec sp_trace_setevent @TraceID, 93, 12, @on
exec sp_trace_setevent @TraceID, 93, 36, @on
exec sp_trace_setevent @TraceID, 93, 60, @on
exec sp_trace_setevent @TraceID, 93, 64, @on
exec sp_trace_setevent @TraceID, 93, 9, @on
exec sp_trace_setevent @TraceID, 93, 13, @on
exec sp_trace_setevent @TraceID, 93, 25, @on
exec sp_trace_setevent @TraceID, 93, 41, @on
exec sp_trace_setevent @TraceID, 93, 10, @on
exec sp_trace_setevent @TraceID, 93, 14, @on
exec sp_trace_setevent @TraceID, 93, 26, @on
exec sp_trace_setevent @TraceID, 93, 3, @on
exec sp_trace_setevent @TraceID, 93, 11, @on
exec sp_trace_setevent @TraceID, 93, 35, @on
exec sp_trace_setevent @TraceID, 93, 51, @on
exec sp_trace_setevent @TraceID, 95, 7, @on
exec sp_trace_setevent @TraceID, 95, 15, @on
exec sp_trace_setevent @TraceID, 95, 8, @on
exec sp_trace_setevent @TraceID, 95, 12, @on
exec sp_trace_setevent @TraceID, 95, 36, @on
exec sp_trace_setevent @TraceID, 95, 60, @on
exec sp_trace_setevent @TraceID, 95, 64, @on
exec sp_trace_setevent @TraceID, 95, 9, @on
exec sp_trace_setevent @TraceID, 95, 13, @on
exec sp_trace_setevent @TraceID, 95, 25, @on
exec sp_trace_setevent @TraceID, 95, 41, @on
exec sp_trace_setevent @TraceID, 95, 10, @on
exec sp_trace_setevent @TraceID, 95, 14, @on
exec sp_trace_setevent @TraceID, 95, 26, @on
exec sp_trace_setevent @TraceID, 95, 3, @on
exec sp_trace_setevent @TraceID, 95, 11, @on
exec sp_trace_setevent @TraceID, 95, 35, @on
exec sp_trace_setevent @TraceID, 95, 51, @on
exec sp_trace_setevent @TraceID, 22, 7, @on
exec sp_trace_setevent @TraceID, 22, 31, @on
exec sp_trace_setevent @TraceID, 22, 8, @on
exec sp_trace_setevent @TraceID, 22, 64, @on
exec sp_trace_setevent @TraceID, 22, 1, @on
exec sp_trace_setevent @TraceID, 22, 9, @on
exec sp_trace_setevent @TraceID, 22, 41, @on
exec sp_trace_setevent @TraceID, 22, 49, @on
exec sp_trace_setevent @TraceID, 22, 6, @on
exec sp_trace_setevent @TraceID, 22, 10, @on
exec sp_trace_setevent @TraceID, 22, 14, @on
exec sp_trace_setevent @TraceID, 22, 26, @on
exec sp_trace_setevent @TraceID, 22, 3, @on
exec sp_trace_setevent @TraceID, 22, 11, @on
exec sp_trace_setevent @TraceID, 22, 35, @on
exec sp_trace_setevent @TraceID, 22, 51, @on
exec sp_trace_setevent @TraceID, 22, 4, @on
exec sp_trace_setevent @TraceID, 22, 12, @on
exec sp_trace_setevent @TraceID, 22, 20, @on
exec sp_trace_setevent @TraceID, 22, 60, @on
exec sp_trace_setevent @TraceID, 55, 7, @on
exec sp_trace_setevent @TraceID, 55, 8, @on
exec sp_trace_setevent @TraceID, 55, 64, @on
exec sp_trace_setevent @TraceID, 55, 9, @on
exec sp_trace_setevent @TraceID, 55, 21, @on
exec sp_trace_setevent @TraceID, 55, 25, @on
exec sp_trace_setevent @TraceID, 55, 41, @on
exec sp_trace_setevent @TraceID, 55, 49, @on
exec sp_trace_setevent @TraceID, 55, 6, @on
exec sp_trace_setevent @TraceID, 55, 10, @on
exec sp_trace_setevent @TraceID, 55, 14, @on
exec sp_trace_setevent @TraceID, 55, 22, @on
exec sp_trace_setevent @TraceID, 55, 26, @on
exec sp_trace_setevent @TraceID, 55, 50, @on
exec sp_trace_setevent @TraceID, 55, 66, @on
exec sp_trace_setevent @TraceID, 55, 3, @on
exec sp_trace_setevent @TraceID, 55, 11, @on
exec sp_trace_setevent @TraceID, 55, 35, @on
exec sp_trace_setevent @TraceID, 55, 51, @on
exec sp_trace_setevent @TraceID, 55, 4, @on
exec sp_trace_setevent @TraceID, 55, 12, @on
exec sp_trace_setevent @TraceID, 55, 60, @on
exec sp_trace_setevent @TraceID, 79, 7, @on
exec sp_trace_setevent @TraceID, 79, 8, @on
exec sp_trace_setevent @TraceID, 79, 64, @on
exec sp_trace_setevent @TraceID, 79, 1, @on
exec sp_trace_setevent @TraceID, 79, 9, @on
exec sp_trace_setevent @TraceID, 79, 41, @on
exec sp_trace_setevent @TraceID, 79, 49, @on
exec sp_trace_setevent @TraceID, 79, 6, @on
exec sp_trace_setevent @TraceID, 79, 10, @on
exec sp_trace_setevent @TraceID, 79, 14, @on
exec sp_trace_setevent @TraceID, 79, 26, @on
exec sp_trace_setevent @TraceID, 79, 50, @on
exec sp_trace_setevent @TraceID, 79, 66, @on
exec sp_trace_setevent @TraceID, 79, 3, @on
exec sp_trace_setevent @TraceID, 79, 11, @on
exec sp_trace_setevent @TraceID, 79, 35, @on
exec sp_trace_setevent @TraceID, 79, 51, @on
exec sp_trace_setevent @TraceID, 79, 4, @on
exec sp_trace_setevent @TraceID, 79, 12, @on
exec sp_trace_setevent @TraceID, 79, 60, @on
exec sp_trace_setevent @TraceID, 80, 7, @on
exec sp_trace_setevent @TraceID, 80, 4, @on
exec sp_trace_setevent @TraceID, 80, 8, @on
exec sp_trace_setevent @TraceID, 80, 12, @on
exec sp_trace_setevent @TraceID, 80, 60, @on
exec sp_trace_setevent @TraceID, 80, 64, @on
exec sp_trace_setevent @TraceID, 80, 9, @on
exec sp_trace_setevent @TraceID, 80, 41, @on
exec sp_trace_setevent @TraceID, 80, 49, @on
exec sp_trace_setevent @TraceID, 80, 6, @on
exec sp_trace_setevent @TraceID, 80, 10, @on
exec sp_trace_setevent @TraceID, 80, 14, @on
exec sp_trace_setevent @TraceID, 80, 26, @on
exec sp_trace_setevent @TraceID, 80, 50, @on
exec sp_trace_setevent @TraceID, 80, 66, @on
exec sp_trace_setevent @TraceID, 80, 3, @on
exec sp_trace_setevent @TraceID, 80, 11, @on
exec sp_trace_setevent @TraceID, 80, 35, @on
exec sp_trace_setevent @TraceID, 80, 51, @on
exec sp_trace_setevent @TraceID, 69, 7, @on
exec sp_trace_setevent @TraceID, 69, 8, @on
exec sp_trace_setevent @TraceID, 69, 64, @on
exec sp_trace_setevent @TraceID, 69, 9, @on
exec sp_trace_setevent @TraceID, 69, 21, @on
exec sp_trace_setevent @TraceID, 69, 41, @on
exec sp_trace_setevent @TraceID, 69, 49, @on
exec sp_trace_setevent @TraceID, 69, 6, @on
exec sp_trace_setevent @TraceID, 69, 10, @on
exec sp_trace_setevent @TraceID, 69, 14, @on
exec sp_trace_setevent @TraceID, 69, 26, @on
exec sp_trace_setevent @TraceID, 69, 50, @on
exec sp_trace_setevent @TraceID, 69, 66, @on
exec sp_trace_setevent @TraceID, 69, 3, @on
exec sp_trace_setevent @TraceID, 69, 11, @on
exec sp_trace_setevent @TraceID, 69, 35, @on
exec sp_trace_setevent @TraceID, 69, 51, @on
exec sp_trace_setevent @TraceID, 69, 4, @on
exec sp_trace_setevent @TraceID, 69, 12, @on
exec sp_trace_setevent @TraceID, 69, 60, @on
exec sp_trace_setevent @TraceID, 157, 3, @on
exec sp_trace_setevent @TraceID, 157, 31, @on
exec sp_trace_setevent @TraceID, 157, 51, @on
exec sp_trace_setevent @TraceID, 157, 4, @on
exec sp_trace_setevent @TraceID, 157, 12, @on
exec sp_trace_setevent @TraceID, 157, 14, @on
exec sp_trace_setevent @TraceID, 157, 22, @on
exec sp_trace_setevent @TraceID, 157, 30, @on
exec sp_trace_setevent @TraceID, 157, 60, @on
exec sp_trace_setevent @TraceID, 157, 64, @on
exec sp_trace_setevent @TraceID, 155, 3, @on
exec sp_trace_setevent @TraceID, 155, 51, @on
exec sp_trace_setevent @TraceID, 155, 4, @on
exec sp_trace_setevent @TraceID, 155, 12, @on
exec sp_trace_setevent @TraceID, 155, 14, @on
exec sp_trace_setevent @TraceID, 155, 22, @on
exec sp_trace_setevent @TraceID, 155, 60, @on
exec sp_trace_setevent @TraceID, 155, 64, @on
exec sp_trace_setevent @TraceID, 155, 1, @on
exec sp_trace_setevent @TraceID, 156, 3, @on
exec sp_trace_setevent @TraceID, 156, 51, @on
exec sp_trace_setevent @TraceID, 156, 4, @on
exec sp_trace_setevent @TraceID, 156, 12, @on
exec sp_trace_setevent @TraceID, 156, 14, @on
exec sp_trace_setevent @TraceID, 156, 22, @on
exec sp_trace_setevent @TraceID, 156, 60, @on
exec sp_trace_setevent @TraceID, 156, 64, @on
exec sp_trace_setevent @TraceID, 164, 7, @on
exec sp_trace_setevent @TraceID, 164, 8, @on
exec sp_trace_setevent @TraceID, 164, 24, @on
exec sp_trace_setevent @TraceID, 164, 56, @on
exec sp_trace_setevent @TraceID, 164, 64, @on
exec sp_trace_setevent @TraceID, 164, 9, @on
exec sp_trace_setevent @TraceID, 164, 25, @on
exec sp_trace_setevent @TraceID, 164, 41, @on
exec sp_trace_setevent @TraceID, 164, 49, @on
exec sp_trace_setevent @TraceID, 164, 6, @on
exec sp_trace_setevent @TraceID, 164, 10, @on
exec sp_trace_setevent @TraceID, 164, 14, @on
exec sp_trace_setevent @TraceID, 164, 22, @on
exec sp_trace_setevent @TraceID, 164, 26, @on
exec sp_trace_setevent @TraceID, 164, 34, @on
exec sp_trace_setevent @TraceID, 164, 50, @on
exec sp_trace_setevent @TraceID, 164, 66, @on
exec sp_trace_setevent @TraceID, 164, 3, @on
exec sp_trace_setevent @TraceID, 164, 11, @on
exec sp_trace_setevent @TraceID, 164, 35, @on
exec sp_trace_setevent @TraceID, 164, 51, @on
exec sp_trace_setevent @TraceID, 164, 4, @on
exec sp_trace_setevent @TraceID, 164, 12, @on
exec sp_trace_setevent @TraceID, 164, 28, @on
exec sp_trace_setevent @TraceID, 164, 52, @on
exec sp_trace_setevent @TraceID, 164, 60, @on
exec sp_trace_setevent @TraceID, 164, 21, @on
exec sp_trace_setevent @TraceID, 46, 7, @on
exec sp_trace_setevent @TraceID, 46, 8, @on
exec sp_trace_setevent @TraceID, 46, 24, @on
exec sp_trace_setevent @TraceID, 46, 56, @on
exec sp_trace_setevent @TraceID, 46, 64, @on
exec sp_trace_setevent @TraceID, 46, 9, @on
exec sp_trace_setevent @TraceID, 46, 25, @on
exec sp_trace_setevent @TraceID, 46, 41, @on
exec sp_trace_setevent @TraceID, 46, 49, @on
exec sp_trace_setevent @TraceID, 46, 6, @on
exec sp_trace_setevent @TraceID, 46, 10, @on
exec sp_trace_setevent @TraceID, 46, 14, @on
exec sp_trace_setevent @TraceID, 46, 22, @on
exec sp_trace_setevent @TraceID, 46, 26, @on
exec sp_trace_setevent @TraceID, 46, 34, @on
exec sp_trace_setevent @TraceID, 46, 50, @on
exec sp_trace_setevent @TraceID, 46, 66, @on
exec sp_trace_setevent @TraceID, 46, 3, @on
exec sp_trace_setevent @TraceID, 46, 11, @on
exec sp_trace_setevent @TraceID, 46, 35, @on
exec sp_trace_setevent @TraceID, 46, 51, @on
exec sp_trace_setevent @TraceID, 46, 4, @on
exec sp_trace_setevent @TraceID, 46, 12, @on
exec sp_trace_setevent @TraceID, 46, 28, @on
exec sp_trace_setevent @TraceID, 46, 52, @on
exec sp_trace_setevent @TraceID, 46, 60, @on
exec sp_trace_setevent @TraceID, 46, 21, @on
exec sp_trace_setevent @TraceID, 47, 7, @on
exec sp_trace_setevent @TraceID, 47, 8, @on
exec sp_trace_setevent @TraceID, 47, 24, @on
exec sp_trace_setevent @TraceID, 47, 56, @on
exec sp_trace_setevent @TraceID, 47, 64, @on
exec sp_trace_setevent @TraceID, 47, 9, @on
exec sp_trace_setevent @TraceID, 47, 25, @on
exec sp_trace_setevent @TraceID, 47, 41, @on
exec sp_trace_setevent @TraceID, 47, 49, @on
exec sp_trace_setevent @TraceID, 47, 6, @on
exec sp_trace_setevent @TraceID, 47, 10, @on
exec sp_trace_setevent @TraceID, 47, 14, @on
exec sp_trace_setevent @TraceID, 47, 22, @on
exec sp_trace_setevent @TraceID, 47, 26, @on
exec sp_trace_setevent @TraceID, 47, 34, @on
exec sp_trace_setevent @TraceID, 47, 50, @on
exec sp_trace_setevent @TraceID, 47, 66, @on
exec sp_trace_setevent @TraceID, 47, 3, @on
exec sp_trace_setevent @TraceID, 47, 11, @on
exec sp_trace_setevent @TraceID, 47, 35, @on
exec sp_trace_setevent @TraceID, 47, 51, @on
exec sp_trace_setevent @TraceID, 47, 4, @on
exec sp_trace_setevent @TraceID, 47, 12, @on
exec sp_trace_setevent @TraceID, 47, 28, @on
exec sp_trace_setevent @TraceID, 47, 52, @on
exec sp_trace_setevent @TraceID, 47, 60, @on
exec sp_trace_setevent @TraceID, 47, 21, @on
exec sp_trace_setevent @TraceID, 109, 7, @on
exec sp_trace_setevent @TraceID, 109, 23, @on
exec sp_trace_setevent @TraceID, 109, 39, @on
exec sp_trace_setevent @TraceID, 109, 8, @on
exec sp_trace_setevent @TraceID, 109, 40, @on
exec sp_trace_setevent @TraceID, 109, 64, @on
exec sp_trace_setevent @TraceID, 109, 9, @on
exec sp_trace_setevent @TraceID, 109, 41, @on
exec sp_trace_setevent @TraceID, 109, 49, @on
exec sp_trace_setevent @TraceID, 109, 10, @on
exec sp_trace_setevent @TraceID, 109, 26, @on
exec sp_trace_setevent @TraceID, 109, 42, @on
exec sp_trace_setevent @TraceID, 109, 50, @on
exec sp_trace_setevent @TraceID, 109, 3, @on
exec sp_trace_setevent @TraceID, 109, 11, @on
exec sp_trace_setevent @TraceID, 109, 35, @on
exec sp_trace_setevent @TraceID, 109, 43, @on
exec sp_trace_setevent @TraceID, 109, 51, @on
exec sp_trace_setevent @TraceID, 109, 4, @on
exec sp_trace_setevent @TraceID, 109, 12, @on
exec sp_trace_setevent @TraceID, 109, 28, @on
exec sp_trace_setevent @TraceID, 109, 44, @on
exec sp_trace_setevent @TraceID, 109, 60, @on
exec sp_trace_setevent @TraceID, 109, 21, @on
exec sp_trace_setevent @TraceID, 109, 29, @on
exec sp_trace_setevent @TraceID, 109, 37, @on
exec sp_trace_setevent @TraceID, 109, 6, @on
exec sp_trace_setevent @TraceID, 109, 14, @on
exec sp_trace_setevent @TraceID, 109, 38, @on
exec sp_trace_setevent @TraceID, 108, 7, @on
exec sp_trace_setevent @TraceID, 108, 23, @on
exec sp_trace_setevent @TraceID, 108, 8, @on
exec sp_trace_setevent @TraceID, 108, 40, @on
exec sp_trace_setevent @TraceID, 108, 64, @on
exec sp_trace_setevent @TraceID, 108, 1, @on
exec sp_trace_setevent @TraceID, 108, 9, @on
exec sp_trace_setevent @TraceID, 108, 41, @on
exec sp_trace_setevent @TraceID, 108, 49, @on
exec sp_trace_setevent @TraceID, 108, 10, @on
exec sp_trace_setevent @TraceID, 108, 26, @on
exec sp_trace_setevent @TraceID, 108, 34, @on
exec sp_trace_setevent @TraceID, 108, 42, @on
exec sp_trace_setevent @TraceID, 108, 50, @on
exec sp_trace_setevent @TraceID, 108, 3, @on
exec sp_trace_setevent @TraceID, 108, 11, @on
exec sp_trace_setevent @TraceID, 108, 35, @on
exec sp_trace_setevent @TraceID, 108, 43, @on
exec sp_trace_setevent @TraceID, 108, 51, @on
exec sp_trace_setevent @TraceID, 108, 4, @on
exec sp_trace_setevent @TraceID, 108, 12, @on
exec sp_trace_setevent @TraceID, 108, 28, @on
exec sp_trace_setevent @TraceID, 108, 60, @on
exec sp_trace_setevent @TraceID, 108, 21, @on
exec sp_trace_setevent @TraceID, 108, 29, @on
exec sp_trace_setevent @TraceID, 108, 37, @on
exec sp_trace_setevent @TraceID, 108, 6, @on
exec sp_trace_setevent @TraceID, 108, 14, @on
exec sp_trace_setevent @TraceID, 108, 38, @on
exec sp_trace_setevent @TraceID, 110, 7, @on
exec sp_trace_setevent @TraceID, 110, 23, @on
exec sp_trace_setevent @TraceID, 110, 39, @on
exec sp_trace_setevent @TraceID, 110, 8, @on
exec sp_trace_setevent @TraceID, 110, 40, @on
exec sp_trace_setevent @TraceID, 110, 64, @on
exec sp_trace_setevent @TraceID, 110, 1, @on
exec sp_trace_setevent @TraceID, 110, 9, @on
exec sp_trace_setevent @TraceID, 110, 41, @on
exec sp_trace_setevent @TraceID, 110, 49, @on
exec sp_trace_setevent @TraceID, 110, 10, @on
exec sp_trace_setevent @TraceID, 110, 26, @on
exec sp_trace_setevent @TraceID, 110, 34, @on
exec sp_trace_setevent @TraceID, 110, 42, @on
exec sp_trace_setevent @TraceID, 110, 50, @on
exec sp_trace_setevent @TraceID, 110, 3, @on
exec sp_trace_setevent @TraceID, 110, 11, @on
exec sp_trace_setevent @TraceID, 110, 35, @on
exec sp_trace_setevent @TraceID, 110, 43, @on
exec sp_trace_setevent @TraceID, 110, 51, @on
exec sp_trace_setevent @TraceID, 110, 4, @on
exec sp_trace_setevent @TraceID, 110, 12, @on
exec sp_trace_setevent @TraceID, 110, 28, @on
exec sp_trace_setevent @TraceID, 110, 60, @on
exec sp_trace_setevent @TraceID, 110, 21, @on
exec sp_trace_setevent @TraceID, 110, 29, @on
exec sp_trace_setevent @TraceID, 110, 37, @on
exec sp_trace_setevent @TraceID, 110, 6, @on
exec sp_trace_setevent @TraceID, 110, 14, @on
exec sp_trace_setevent @TraceID, 110, 38, @on
exec sp_trace_setevent @TraceID, 111, 7, @on
exec sp_trace_setevent @TraceID, 111, 23, @on
exec sp_trace_setevent @TraceID, 111, 8, @on
exec sp_trace_setevent @TraceID, 111, 40, @on
exec sp_trace_setevent @TraceID, 111, 64, @on
exec sp_trace_setevent @TraceID, 111, 9, @on
exec sp_trace_setevent @TraceID, 111, 41, @on
exec sp_trace_setevent @TraceID, 111, 49, @on
exec sp_trace_setevent @TraceID, 111, 6, @on
exec sp_trace_setevent @TraceID, 111, 10, @on
exec sp_trace_setevent @TraceID, 111, 14, @on
exec sp_trace_setevent @TraceID, 111, 26, @on
exec sp_trace_setevent @TraceID, 111, 38, @on
exec sp_trace_setevent @TraceID, 111, 50, @on
exec sp_trace_setevent @TraceID, 111, 3, @on
exec sp_trace_setevent @TraceID, 111, 11, @on
exec sp_trace_setevent @TraceID, 111, 35, @on
exec sp_trace_setevent @TraceID, 111, 51, @on
exec sp_trace_setevent @TraceID, 111, 4, @on
exec sp_trace_setevent @TraceID, 111, 12, @on
exec sp_trace_setevent @TraceID, 111, 28, @on
exec sp_trace_setevent @TraceID, 111, 60, @on
exec sp_trace_setevent @TraceID, 111, 21, @on
exec sp_trace_setevent @TraceID, 111, 29, @on
exec sp_trace_setevent @TraceID, 104, 7, @on
exec sp_trace_setevent @TraceID, 104, 23, @on
exec sp_trace_setevent @TraceID, 104, 8, @on
exec sp_trace_setevent @TraceID, 104, 40, @on
exec sp_trace_setevent @TraceID, 104, 64, @on
exec sp_trace_setevent @TraceID, 104, 9, @on
exec sp_trace_setevent @TraceID, 104, 41, @on
exec sp_trace_setevent @TraceID, 104, 49, @on
exec sp_trace_setevent @TraceID, 104, 6, @on
exec sp_trace_setevent @TraceID, 104, 10, @on
exec sp_trace_setevent @TraceID, 104, 14, @on
exec sp_trace_setevent @TraceID, 104, 26, @on
exec sp_trace_setevent @TraceID, 104, 42, @on
exec sp_trace_setevent @TraceID, 104, 50, @on
exec sp_trace_setevent @TraceID, 104, 3, @on
exec sp_trace_setevent @TraceID, 104, 11, @on
exec sp_trace_setevent @TraceID, 104, 35, @on
exec sp_trace_setevent @TraceID, 104, 43, @on
exec sp_trace_setevent @TraceID, 104, 51, @on
exec sp_trace_setevent @TraceID, 104, 4, @on
exec sp_trace_setevent @TraceID, 104, 12, @on
exec sp_trace_setevent @TraceID, 104, 28, @on
exec sp_trace_setevent @TraceID, 104, 60, @on
exec sp_trace_setevent @TraceID, 104, 5, @on
exec sp_trace_setevent @TraceID, 104, 21, @on
exec sp_trace_setevent @TraceID, 115, 7, @on
exec sp_trace_setevent @TraceID, 115, 23, @on
exec sp_trace_setevent @TraceID, 115, 8, @on
exec sp_trace_setevent @TraceID, 115, 40, @on
exec sp_trace_setevent @TraceID, 115, 64, @on
exec sp_trace_setevent @TraceID, 115, 1, @on
exec sp_trace_setevent @TraceID, 115, 9, @on
exec sp_trace_setevent @TraceID, 115, 41, @on
exec sp_trace_setevent @TraceID, 115, 49, @on
exec sp_trace_setevent @TraceID, 115, 6, @on
exec sp_trace_setevent @TraceID, 115, 10, @on
exec sp_trace_setevent @TraceID, 115, 14, @on
exec sp_trace_setevent @TraceID, 115, 26, @on
exec sp_trace_setevent @TraceID, 115, 34, @on
exec sp_trace_setevent @TraceID, 115, 50, @on
exec sp_trace_setevent @TraceID, 115, 3, @on
exec sp_trace_setevent @TraceID, 115, 11, @on
exec sp_trace_setevent @TraceID, 115, 35, @on
exec sp_trace_setevent @TraceID, 115, 51, @on
exec sp_trace_setevent @TraceID, 115, 4, @on
exec sp_trace_setevent @TraceID, 115, 12, @on
exec sp_trace_setevent @TraceID, 115, 28, @on
exec sp_trace_setevent @TraceID, 115, 60, @on
exec sp_trace_setevent @TraceID, 115, 5, @on
exec sp_trace_setevent @TraceID, 115, 21, @on
exec sp_trace_setevent @TraceID, 115, 29, @on
exec sp_trace_setevent @TraceID, 115, 37, @on
exec sp_trace_setevent @TraceID, 152, 7, @on
exec sp_trace_setevent @TraceID, 152, 23, @on
exec sp_trace_setevent @TraceID, 152, 39, @on
exec sp_trace_setevent @TraceID, 152, 8, @on
exec sp_trace_setevent @TraceID, 152, 40, @on
exec sp_trace_setevent @TraceID, 152, 64, @on
exec sp_trace_setevent @TraceID, 152, 1, @on
exec sp_trace_setevent @TraceID, 152, 9, @on
exec sp_trace_setevent @TraceID, 152, 41, @on
exec sp_trace_setevent @TraceID, 152, 49, @on
exec sp_trace_setevent @TraceID, 152, 10, @on
exec sp_trace_setevent @TraceID, 152, 26, @on
exec sp_trace_setevent @TraceID, 152, 34, @on
exec sp_trace_setevent @TraceID, 152, 42, @on
exec sp_trace_setevent @TraceID, 152, 50, @on
exec sp_trace_setevent @TraceID, 152, 3, @on
exec sp_trace_setevent @TraceID, 152, 11, @on
exec sp_trace_setevent @TraceID, 152, 35, @on
exec sp_trace_setevent @TraceID, 152, 43, @on
exec sp_trace_setevent @TraceID, 152, 51, @on
exec sp_trace_setevent @TraceID, 152, 4, @on
exec sp_trace_setevent @TraceID, 152, 12, @on
exec sp_trace_setevent @TraceID, 152, 28, @on
exec sp_trace_setevent @TraceID, 152, 60, @on
exec sp_trace_setevent @TraceID, 152, 29, @on
exec sp_trace_setevent @TraceID, 152, 37, @on
exec sp_trace_setevent @TraceID, 152, 6, @on
exec sp_trace_setevent @TraceID, 152, 14, @on
exec sp_trace_setevent @TraceID, 116, 7, @on
exec sp_trace_setevent @TraceID, 116, 23, @on
exec sp_trace_setevent @TraceID, 116, 8, @on
exec sp_trace_setevent @TraceID, 116, 40, @on
exec sp_trace_setevent @TraceID, 116, 64, @on
exec sp_trace_setevent @TraceID, 116, 1, @on
exec sp_trace_setevent @TraceID, 116, 9, @on
exec sp_trace_setevent @TraceID, 116, 41, @on
exec sp_trace_setevent @TraceID, 116, 49, @on
exec sp_trace_setevent @TraceID, 116, 6, @on
exec sp_trace_setevent @TraceID, 116, 10, @on
exec sp_trace_setevent @TraceID, 116, 14, @on
exec sp_trace_setevent @TraceID, 116, 26, @on
exec sp_trace_setevent @TraceID, 116, 50, @on
exec sp_trace_setevent @TraceID, 116, 3, @on
exec sp_trace_setevent @TraceID, 116, 11, @on
exec sp_trace_setevent @TraceID, 116, 35, @on
exec sp_trace_setevent @TraceID, 116, 51, @on
exec sp_trace_setevent @TraceID, 116, 4, @on
exec sp_trace_setevent @TraceID, 116, 12, @on
exec sp_trace_setevent @TraceID, 116, 44, @on
exec sp_trace_setevent @TraceID, 116, 60, @on
exec sp_trace_setevent @TraceID, 116, 5, @on
exec sp_trace_setevent @TraceID, 116, 29, @on
exec sp_trace_setevent @TraceID, 116, 37, @on
exec sp_trace_setevent @TraceID, 102, 7, @on
exec sp_trace_setevent @TraceID, 102, 23, @on
exec sp_trace_setevent @TraceID, 102, 39, @on
exec sp_trace_setevent @TraceID, 102, 8, @on
exec sp_trace_setevent @TraceID, 102, 40, @on
exec sp_trace_setevent @TraceID, 102, 64, @on
exec sp_trace_setevent @TraceID, 102, 1, @on
exec sp_trace_setevent @TraceID, 102, 9, @on
exec sp_trace_setevent @TraceID, 102, 41, @on
exec sp_trace_setevent @TraceID, 102, 49, @on
exec sp_trace_setevent @TraceID, 102, 10, @on
exec sp_trace_setevent @TraceID, 102, 26, @on
exec sp_trace_setevent @TraceID, 102, 34, @on
exec sp_trace_setevent @TraceID, 102, 42, @on
exec sp_trace_setevent @TraceID, 102, 50, @on
exec sp_trace_setevent @TraceID, 102, 3, @on
exec sp_trace_setevent @TraceID, 102, 11, @on
exec sp_trace_setevent @TraceID, 102, 19, @on
exec sp_trace_setevent @TraceID, 102, 35, @on
exec sp_trace_setevent @TraceID, 102, 43, @on
exec sp_trace_setevent @TraceID, 102, 51, @on
exec sp_trace_setevent @TraceID, 102, 4, @on
exec sp_trace_setevent @TraceID, 102, 12, @on
exec sp_trace_setevent @TraceID, 102, 28, @on
exec sp_trace_setevent @TraceID, 102, 60, @on
exec sp_trace_setevent @TraceID, 102, 5, @on
exec sp_trace_setevent @TraceID, 102, 21, @on
exec sp_trace_setevent @TraceID, 102, 29, @on
exec sp_trace_setevent @TraceID, 102, 37, @on
exec sp_trace_setevent @TraceID, 102, 6, @on
exec sp_trace_setevent @TraceID, 102, 14, @on
exec sp_trace_setevent @TraceID, 106, 7, @on
exec sp_trace_setevent @TraceID, 106, 23, @on
exec sp_trace_setevent @TraceID, 106, 8, @on
exec sp_trace_setevent @TraceID, 106, 40, @on
exec sp_trace_setevent @TraceID, 106, 64, @on
exec sp_trace_setevent @TraceID, 106, 1, @on
exec sp_trace_setevent @TraceID, 106, 9, @on
exec sp_trace_setevent @TraceID, 106, 41, @on
exec sp_trace_setevent @TraceID, 106, 49, @on
exec sp_trace_setevent @TraceID, 106, 10, @on
exec sp_trace_setevent @TraceID, 106, 26, @on
exec sp_trace_setevent @TraceID, 106, 34, @on
exec sp_trace_setevent @TraceID, 106, 42, @on
exec sp_trace_setevent @TraceID, 106, 50, @on
exec sp_trace_setevent @TraceID, 106, 3, @on
exec sp_trace_setevent @TraceID, 106, 11, @on
exec sp_trace_setevent @TraceID, 106, 35, @on
exec sp_trace_setevent @TraceID, 106, 43, @on
exec sp_trace_setevent @TraceID, 106, 51, @on
exec sp_trace_setevent @TraceID, 106, 4, @on
exec sp_trace_setevent @TraceID, 106, 12, @on
exec sp_trace_setevent @TraceID, 106, 28, @on
exec sp_trace_setevent @TraceID, 106, 60, @on
exec sp_trace_setevent @TraceID, 106, 5, @on
exec sp_trace_setevent @TraceID, 106, 21, @on
exec sp_trace_setevent @TraceID, 106, 29, @on
exec sp_trace_setevent @TraceID, 106, 37, @on
exec sp_trace_setevent @TraceID, 106, 6, @on
exec sp_trace_setevent @TraceID, 106, 14, @on
exec sp_trace_setevent @TraceID, 20, 7, @on
exec sp_trace_setevent @TraceID, 20, 23, @on
exec sp_trace_setevent @TraceID, 20, 31, @on
exec sp_trace_setevent @TraceID, 20, 8, @on
exec sp_trace_setevent @TraceID, 20, 64, @on
exec sp_trace_setevent @TraceID, 20, 1, @on
exec sp_trace_setevent @TraceID, 20, 9, @on
exec sp_trace_setevent @TraceID, 20, 21, @on
exec sp_trace_setevent @TraceID, 20, 49, @on
exec sp_trace_setevent @TraceID, 20, 57, @on
exec sp_trace_setevent @TraceID, 20, 6, @on
exec sp_trace_setevent @TraceID, 20, 10, @on
exec sp_trace_setevent @TraceID, 20, 14, @on
exec sp_trace_setevent @TraceID, 20, 26, @on
exec sp_trace_setevent @TraceID, 20, 30, @on
exec sp_trace_setevent @TraceID, 20, 3, @on
exec sp_trace_setevent @TraceID, 20, 11, @on
exec sp_trace_setevent @TraceID, 20, 35, @on
exec sp_trace_setevent @TraceID, 20, 51, @on
exec sp_trace_setevent @TraceID, 20, 12, @on
exec sp_trace_setevent @TraceID, 20, 60, @on
exec sp_trace_setevent @TraceID, 105, 7, @on
exec sp_trace_setevent @TraceID, 105, 23, @on
exec sp_trace_setevent @TraceID, 105, 8, @on
exec sp_trace_setevent @TraceID, 105, 40, @on
exec sp_trace_setevent @TraceID, 105, 64, @on
exec sp_trace_setevent @TraceID, 105, 9, @on
exec sp_trace_setevent @TraceID, 105, 41, @on
exec sp_trace_setevent @TraceID, 105, 49, @on
exec sp_trace_setevent @TraceID, 105, 6, @on
exec sp_trace_setevent @TraceID, 105, 10, @on
exec sp_trace_setevent @TraceID, 105, 14, @on
exec sp_trace_setevent @TraceID, 105, 26, @on
exec sp_trace_setevent @TraceID, 105, 42, @on
exec sp_trace_setevent @TraceID, 105, 50, @on
exec sp_trace_setevent @TraceID, 105, 3, @on
exec sp_trace_setevent @TraceID, 105, 11, @on
exec sp_trace_setevent @TraceID, 105, 35, @on
exec sp_trace_setevent @TraceID, 105, 43, @on
exec sp_trace_setevent @TraceID, 105, 51, @on
exec sp_trace_setevent @TraceID, 105, 4, @on
exec sp_trace_setevent @TraceID, 105, 12, @on
exec sp_trace_setevent @TraceID, 105, 28, @on
exec sp_trace_setevent @TraceID, 105, 60, @on
exec sp_trace_setevent @TraceID, 105, 21, @on
exec sp_trace_setevent @TraceID, 103, 7, @on
exec sp_trace_setevent @TraceID, 103, 23, @on
exec sp_trace_setevent @TraceID, 103, 39, @on
exec sp_trace_setevent @TraceID, 103, 8, @on
exec sp_trace_setevent @TraceID, 103, 40, @on
exec sp_trace_setevent @TraceID, 103, 64, @on
exec sp_trace_setevent @TraceID, 103, 1, @on
exec sp_trace_setevent @TraceID, 103, 9, @on
exec sp_trace_setevent @TraceID, 103, 41, @on
exec sp_trace_setevent @TraceID, 103, 49, @on
exec sp_trace_setevent @TraceID, 103, 10, @on
exec sp_trace_setevent @TraceID, 103, 26, @on
exec sp_trace_setevent @TraceID, 103, 34, @on
exec sp_trace_setevent @TraceID, 103, 42, @on
exec sp_trace_setevent @TraceID, 103, 50, @on
exec sp_trace_setevent @TraceID, 103, 3, @on
exec sp_trace_setevent @TraceID, 103, 11, @on
exec sp_trace_setevent @TraceID, 103, 19, @on
exec sp_trace_setevent @TraceID, 103, 35, @on
exec sp_trace_setevent @TraceID, 103, 43, @on
exec sp_trace_setevent @TraceID, 103, 51, @on
exec sp_trace_setevent @TraceID, 103, 59, @on
exec sp_trace_setevent @TraceID, 103, 4, @on
exec sp_trace_setevent @TraceID, 103, 12, @on
exec sp_trace_setevent @TraceID, 103, 28, @on
exec sp_trace_setevent @TraceID, 103, 44, @on
exec sp_trace_setevent @TraceID, 103, 60, @on
exec sp_trace_setevent @TraceID, 103, 5, @on
exec sp_trace_setevent @TraceID, 103, 21, @on
exec sp_trace_setevent @TraceID, 103, 29, @on
exec sp_trace_setevent @TraceID, 103, 37, @on
exec sp_trace_setevent @TraceID, 103, 6, @on
exec sp_trace_setevent @TraceID, 103, 14, @on
exec sp_trace_setevent @TraceID, 153, 7, @on
exec sp_trace_setevent @TraceID, 153, 23, @on
exec sp_trace_setevent @TraceID, 153, 39, @on
exec sp_trace_setevent @TraceID, 153, 8, @on
exec sp_trace_setevent @TraceID, 153, 40, @on
exec sp_trace_setevent @TraceID, 153, 64, @on
exec sp_trace_setevent @TraceID, 153, 1, @on
exec sp_trace_setevent @TraceID, 153, 41, @on
exec sp_trace_setevent @TraceID, 153, 49, @on
exec sp_trace_setevent @TraceID, 153, 10, @on
exec sp_trace_setevent @TraceID, 153, 26, @on
exec sp_trace_setevent @TraceID, 153, 34, @on
exec sp_trace_setevent @TraceID, 153, 42, @on
exec sp_trace_setevent @TraceID, 153, 50, @on
exec sp_trace_setevent @TraceID, 153, 3, @on
exec sp_trace_setevent @TraceID, 153, 11, @on
exec sp_trace_setevent @TraceID, 153, 35, @on
exec sp_trace_setevent @TraceID, 153, 43, @on
exec sp_trace_setevent @TraceID, 153, 51, @on
exec sp_trace_setevent @TraceID, 153, 59, @on
exec sp_trace_setevent @TraceID, 153, 4, @on
exec sp_trace_setevent @TraceID, 153, 12, @on
exec sp_trace_setevent @TraceID, 153, 28, @on
exec sp_trace_setevent @TraceID, 153, 60, @on
exec sp_trace_setevent @TraceID, 153, 29, @on
exec sp_trace_setevent @TraceID, 153, 37, @on
exec sp_trace_setevent @TraceID, 153, 6, @on
exec sp_trace_setevent @TraceID, 153, 14, @on
exec sp_trace_setevent @TraceID, 18, 7, @on
exec sp_trace_setevent @TraceID, 18, 23, @on
exec sp_trace_setevent @TraceID, 18, 8, @on
exec sp_trace_setevent @TraceID, 18, 12, @on
exec sp_trace_setevent @TraceID, 18, 60, @on
exec sp_trace_setevent @TraceID, 18, 64, @on
exec sp_trace_setevent @TraceID, 18, 9, @on
exec sp_trace_setevent @TraceID, 18, 21, @on
exec sp_trace_setevent @TraceID, 18, 41, @on
exec sp_trace_setevent @TraceID, 18, 49, @on
exec sp_trace_setevent @TraceID, 18, 6, @on
exec sp_trace_setevent @TraceID, 18, 10, @on
exec sp_trace_setevent @TraceID, 18, 14, @on
exec sp_trace_setevent @TraceID, 18, 26, @on
exec sp_trace_setevent @TraceID, 18, 11, @on
exec sp_trace_setevent @TraceID, 18, 51, @on
exec sp_trace_setevent @TraceID, 81, 51, @on
exec sp_trace_setevent @TraceID, 81, 4, @on
exec sp_trace_setevent @TraceID, 81, 12, @on
exec sp_trace_setevent @TraceID, 81, 14, @on
exec sp_trace_setevent @TraceID, 81, 26, @on
exec sp_trace_setevent @TraceID, 81, 50, @on
exec sp_trace_setevent @TraceID, 81, 60, @on
exec sp_trace_setevent @TraceID, 81, 64, @on
exec sp_trace_setevent @TraceID, 81, 21, @on
exec sp_trace_setevent @TraceID, 81, 25, @on
exec sp_trace_setevent @TraceID, 81, 49, @on


-- Set the Filters
declare @intfilter int
declare @bigintfilter bigint

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

EXECUTE sp_procoption @procname = 'sp_custom_default_trace', @optionname = 'startup', @optionvalue = 'true';

GO