笔记332 关闭SQLSERVER的默认跟踪 不能使用sp_trace_setstatus 2013-7-24

笔记332 关闭SQLSERVER的默认跟踪 不能使用sp_trace_setstatus 2013-7-24

 1 --关闭SQLSERVER的默认跟踪 不能使用sp_trace_setstatus 2013-7-24
 2 SELECT  * FROM    sys.traces
 3 
 4 EXEC sp_trace_setstatus @traceid = 1, @status = 0
 5 
 6 ---------------------------------------------------
 7 --消息 19070,级别 16,状态 1,过程 sp_trace_setstatus,第 1 行
 8 --无法停止或修改默认跟踪。请使用 SP_CONFIGURE 将其关闭。
 9 
10 --只能使用sp_configure来关闭default trace
11 EXEC sp_configure 'show advanced options', 1;
12 GO
13 RECONFIGURE;
14 GO
15 EXEC sp_configure 'default trace enabled', 0;
16 GO
17 RECONFIGURE;
18 GO
19 
20 ------------------------------------------------------
21 --http://msdn.microsoft.com/en-us/library/ms176034.aspx
22 --关于sp_trace_setstatus的参数
23 [ @traceid= ] trace_id
24 Is the ID of the trace to be modified. trace_id is int, with no default. The user employs this trace_id value to identify, modify, and control the trace. For information about retrieving the trace_id, see sys.fn_trace_getinfo (Transact-SQL).
25 [ @status= ] status
26 Specifies the action to implement on the trace. status is int, with no default.
27 The following table lists the status that may be specified.
28 Status
29 Description
30 0:Stops the specified trace.
31 1:Starts the specified trace.
32 2:Closes the specified trace and deletes its definition from the server.
33 ---------------------------------------------------------
34 --关于sp_trace_setstatus的Return Code Values
35 The following table describes the code values that users may get following completion of the stored procedure.
36 Return code
37 Description
38 0
39 No error.
40 1
41 Unknown error.
42 8
43 The specified Status is not valid.
44 9
45 The specified Trace Handle is not valid.
46 13
47 Out of memory. Returned when there is not enough memory to perform the specified action.

 

posted @ 2013-08-04 22:01  桦仔  阅读(2517)  评论(0编辑  收藏  举报