DBCC TRACEON/TRACEOFF/TRACESTATUS
1. enable trace
DBCC TRACEON ( trace# [ ,...n ][ , -1 ] ) [ WITH NO_INFOMSGS ] trace# Is the number of the trace flag to turn on.
n Is a placeholder that indicates multiple trace flags can be specified.
-1 Switches on the specified trace flags globally.
WITH NO_INFOMSGS Suppresses all informational messages.
On a production server, to avoid unpredictable behavior, we recommend that you only enable trace flags server-wide by using one of the following methods:
Use the -T command-line startup option of Sqlservr.exe. This is a recommended best practice because it makes sure that all statements will run with the trace flag enabled.
These include commands in startup scripts. For more information, see sqlservr Application.
Use DBCC TRACEON ( trace# [, ....n], -1 ) only while users or applications are not concurrently running statements on the system.
Trace flags are used to customize certain characteristics by controlling how SQL Server operates. Trace flags, after they are enabled, remain enabled in the server until disabled by executing a DBCC TRACEOFF statement. In SQL Server, there are two types of trace flags: session and global. Session trace flags are active for a connection and are visible only for that connection. Global trace flags are set at the server level and are visible to every connection on the server. To determine the status of trace flags, use DBCC TRACESTATUS. To disable trace flags, use DBCC TRACEOFF.
the following example disables hardware compression for tape drivers, by switching on trace flag 3205. This flag is switched on only for the current connection.
DBCC TRACEON (3205);
GO
The following example switches on trace flag 3205 globally.
DBCC TRACEON (3205, -1);
GO
The following example switches on trace flags 3205, and 260 globally.
DBCC TRACEON (3205, 260, -1);
GO
2. disable the trace flag. DBCC TRACEOFF ( trace# [ ,...n ] [ , -1 ] ) [ WITH NO_INFOMSGS ] trace# Is the number of the trace flag to disable.
-1 Disables the specified trace flags globally.
WITH NO_INFOMSGS Suppresses all informational messages that have severity levels from 0 through 10.
The following example disables trace flag 3205.
DBCC TRACEOFF (3205);
GO
The following example first disables trace flag 3205 globally
DBCC TRACEOFF (3205, -1);
GO
The following example disables trace flags 3205 and 260 globally.
DBCC TRACEOFF (3205, 260, -1);
GO 3.check the trace flag
DBCC TRACESTATUS ( [ [ trace# [ ,...n ] ] [ , ] [ -1 ] ] ) [ WITH NO_INFOMSGS ]
- trace# Is the number of the trace flag for which the status is displayed. If trace#, and -1 are not specified, all trace flags that are enabled for the session are displayed.
- n Is a placeholder that indicates multiple trace flags can be specified.
- -1 Displays the status of trace flags that are enabled globally. If -1 is specified without trace#, all the global trace flags that are enabled are displayed.
- WITH NO_INFOMSGS Suppresses all informational messages that have severity levels from 0 through 10.
The following table describes the information in the result set.
|
Column name |
Description |
|---|---|
|
TraceFlag |
Name of trace flag |
|
Status |
Indicates whether the trace flag is set ON of OFF, either globally or for the session. 1 = ON 0 = OFF |
|
Global |
Indicates whether the trace flag is set globally 1 = True 0 = False |
|
Session |
Indicates whether the trace flag is set for the session 1 = True 0 = False |
DBCC TRACESTATUS returns a column for the trace flag number and a column for the status. This indicates whether the trace flag is ON (1) or OFF (0).
The column heading for the trace flag number is either Global Trace Flag or Session Trace Flag, depending on whether you are checking the status for a global or a session trace flag.
The following example displays the status of all trace flags that are currently enabled globally.
DBCC TRACESTATUS(-1);
GO
The following example displays the status of trace flags 2528 and 3205.
DBCC TRACESTATUS (2528, 3205);
GO
The following example displays whether trace flag 3205 is enabled globally.
DBCC TRACESTATUS (3205, -1);
GO
The following example lists all the trace flags that are enabled for the current session.
DBCC TRACESTATUS();
GO 备注:
如果开的是global的trace flag,那么也只能通过disable global的trace flag,也就是要带 -1 作为参数. DBCC TRACEON(3605,1222,1204,-1)
DBCC TRACESTATU(-1) DBCC TRACEOFF(3605,1222,1204,-1)
DBCC TRACEON/TRACEOFF/TRACESTATUS的更多相关文章
- DBCC TRACEON - 跟踪标志 (Transact-SQL)
跟踪标志用于设置特定服务器特征或更改特定行为. 例如,跟踪标志 3226 是一种常用的启动跟踪标志,可取消显示错误日志中的成功备份消息. 跟踪标志经常用于诊断性能问题或调试存储过程或复杂的计算机系统, ...
- (4.5)DBCC的概念与用法(DBCC TRACEON、DBCC IND、DBCC PAGE)
转自:http://www.cnblogs.com/huangxincheng/p/4249248.html DBCC的概念与用法 一:DBCC 1:什么是DBCC 我不是教学老师,我也说不到没有任何 ...
- DBCC常用命令小汇
DBCC是SQL Server提供的一组控制台命令,功能很强大,掌握一些必要的语句,对操作数据库有不少帮助,所以决定整理一下,发现已有不少类似的整理,减少了不少工作,归类如下: 一.DBCC 帮助类命 ...
- DBCC用法汇总
本文摘自http://www.cnblogs.com/lilycnblogs/archive/2011/03/31/2001372.html 留作查阅 DBCC是SQL Server提供的一组控制台命 ...
- [转]DBCC (Transact-SQL)
http://msdn.microsoft.com/zh-cn/library/ms188796.aspx Transact-SQL 编程语言提供 DBCC 语句以作为 SQL Server 的数据库 ...
- DBCC命令
DBCC SQLMGRSTATS 用于产生3个不同的值,这些值用在你想查看高速缓存在ad-hoc和预编译的TSQL语句中是如何工作的 Memory Used(8K Pages):若内存页的数量非常大, ...
- List Available DBCC Commands
DBCC Commands or Database Consistency Checker commands have been with SQL Server from its early ages ...
- sql server 碎片整理——DBCC SHOWCONTIG
转自: 1.http://blog.sina.com.cn/s/blog_6d2675450101ks6i.html 2.http://www.cnblogs.com/CareySon/archive ...
- SQL Server 2000 ——DBCC命令
http://blog.163.com/ruifeng_00/blog/static/6904584200971291923462/ 一.定义 微软当初从SYBASE将DBCC是作为数据库一致性检 ...
随机推荐
- HTML<marquee>标签
<marquee>标签,它是成对出现的标签,首标签<marquee>和尾标签</marquee>之间的内容就是滚动内容.<marquee>标签的属性主要 ...
- Easyui的datagrid结合hibernate实现数据分页
最近在学习easyui的使用,在学到datagrid的时候遇到了一些问题,终于抽点时间整理了一下,分享出来,请各位前辈高手多多指教! 1.先来看看效果,二话不说,上图直观! 2.easyui的data ...
- 你能不用计算机来计算S=a+(a+1)+(a+2) + ...... + b的解的数目吗?
S=a + (a + 1) + (a + 2) + ...... + b(其中a, b > 0) 现在我们要求,给定一个正整数S,求有多少种不同的<a,b>,使得上述的等式成立. 这 ...
- [转]在Entity Framework中使用LINQ语句分页
本文转自:http://diaosbook.com/Post/2012/9/21/linq-paging-in-entity-framework 我们知道,内存分页效率很低.并且,如果是WebForm ...
- 【液晶模块系列基础视频】1.2.iM_RGB模块介绍
[液晶模块系列基础视频]1.2.iM_RGB模块介绍(上) [液晶模块系列基础视频]1.2.iM_RGB模块介绍(下) ============================== 技术论坛:http ...
- HDR Defered Shading (using MRT)
http://http.download.nvidia.com/developer/SDK/Individual_Samples/DEMOS/Direct3D9/DeferredShading.zip ...
- Nginx 笔记与总结(8)Location:归纳总结
首先对 URI 进行精准匹配,如果匹配上则退出匹配,返回精准匹配结果: 如果没有匹配上则寻找普通匹配,如果命中多个普通匹配,则记忆最长的匹配结果(不考虑 location 的顺序): 如果后面还有正则 ...
- 未在本地计算机上注册“Microsoft.ACE.OLEDB.12.0”提供程序。
笔记本装的是windows 7旗舰版64位系统,使用的是MS Office 2007(Microsoft.ACE.OLEDB.12.0,32位程序),开发用的是Visual Studio 2010,我 ...
- Bootstrap页面布局22 - BS工具提示
当鼠标点击在一个a连接上时,显示提示文字的效果 ---------------- tooltip <div class='container-fluid'> <h3 class=' ...
- 利用Excel画柱状图,并且包含最大最小值
如何利用Excel画出如上样式的图? 1.绘制柱状图.如何绘制柱状图,操作非常简单,选中数据,点击合适的图表样式即可. 2.添加误差线.选中已绘制好的图,添加误差线.如果误差线没有出现,可以使用”更多 ...