top

笔记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 @   桦仔  阅读(2551)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
点击右上角即可分享
微信分享提示