1
2 /*
3 ** sp_monitor_trace
4 **
5 ** Utility procedure to update the trace level in the control table
6 ** in tempdb.
7 **
8 ** Usage: sp_monitor trace, '1'
9 ** sp_monitor trace, '2'
10 {
11 */
12 create procedure sp_monitor_trace(
13 @trace_str varchar(10) = 'a'
14 ) as
15 begin
16 declare @trace int
17 , @nrows int
18
19 if (@trace_str IS NULL)
20 return 0
21
22 -- If a valid integer was passed, update the trace level.
23 if (patindex("%[^0-9]%", @trace_str) = 0)
24 begin
25 select @trace = convert(int, @trace_str)
26
27 update tempdb.dbo.mon_config
28 set configval = @trace
29 where monitor = 'tracing'
30
31 select @nrows = @@rowcount
32 if (@nrows > 0)
33 begin
34 print "Updated trace level to %1!. (%2! row(s) affected.)"
35 , @trace, @nrows
36 end
37 end
38 else
39 begin
40 raiserror 19060, 'sp_monitor_trace', @trace_str
41 return 1
42 end
43
44 return 0
45 end -- }
46
exec sp_procxmode 'sp_monitor_trace', 'AnyMode'
go
Grant Execute on sp_monitor_trace to public
go