sp_trace_setfilter sqlserver筛选跟踪或跟踪过滤

sp_trace_setfilter

sp_trace_setfilter [ @traceid = ] trace_id   
          , [ @columnid = ] column_id  
          , [ @logical_operator = ] logical_operator  
          , [ @comparison_operator = ] comparison_operator  
          , [ @value = ] value  


Examples
The following example sets three filters on Trace 1.
The filters N'SQLT%' and N'MS%' operate on one column (AppName, value 10) using the "LIKE" comparison operator.
The filter N'joe' operates on a different column (UserName, value 11) using the "EQUAL" comparison operator.

sp_trace_setfilter  1, 10, 0, 6, N'SQLT%';  
sp_trace_setfilter  1, 10, 0, 6, N'MS%';  
sp_trace_setfilter  1, 11, 0, 0, N'joe';  

 

ValueComparison operator
0 = (Equal)
1 <> (Not Equal)
2 > (Greater Than)
3 < (Less Than)
4 >= (Greater Than Or Equal)
5 <= (Less Than Or Equal)
6 LIKE
7 NOT LIKE

 

 

 

 

 

 

 

 

 

筛选器可用性取决于数据列。 某些数据列无法筛选。 可筛选的数据列只能使用部分关系运算符进行筛选,如下表所示。

 

关系运算符运算符说明
Like Like 指定跟踪事件数据必须类似于输入文本。 允许使用多个值。
不类似于 不类似于 指定跟踪事件数据不能与输入文本类似。 允许使用多个值。
等于 = 指定跟踪事件数据必须等于输入的值。 允许使用多个值。
不等于 <> 指定跟踪事件数据不能等于输入的值。 允许使用多个值。
大于 > 指定跟踪事件数据必须大于输入的值。
大于或等于 >= 指定跟踪事件数据必须大于或等于输入的值。
小于 < 指定跟踪事件数据必须小于输入的值。
小于或等于 <= 指定跟踪事件数据必须小于或等于输入的值。

 

 

 

 

 

 

 

 

 

下表列出了可筛选数据列和可用关系运算符。

数据列关系运算符
ApplicationName LIKE、NOT LIKE
BigintData1 =, <>, >=, <=
BigintData2 =, <>, >=, <=
BinaryData 使用 SQL Server 事件探查器 筛选此数据列中的事件。 有关详细信息,请参阅 使用 SQL Server Profiler 筛选跟踪
ClientProcessID =, <>, >=, <=
ColumnPermissions =, <>, >=, <=
CPU =, <>, >=, <=
DatabaseID =, <>, >=, <=
DatabaseName LIKE、NOT LIKE
DBUserName LIKE、NOT LIKE
Duration =, <>, >=, <=
EndTime >=, <=
错误 =, <>, >=, <=
EventSubClass =, <>, >=, <=
FileName LIKE、NOT LIKE
GUID 使用 SQL Server 事件探查器 筛选此数据列中的事件。 有关详细信息,请参阅 使用 SQL Server Profiler 筛选跟踪
Handle =, <>, >=, <=
HostName LIKE、NOT LIKE
IndexID =, <>, >=, <=
IntegerData =, <>, >=, <=
IntegerData2 =, <>, >=, <=
IsSystem =, <>, >=, <=
LineNumber =, <>, >=, <=
LinkedServerName LIKE、NOT LIKE
LoginName LIKE、NOT LIKE
LoginSid 使用 SQL Server 事件探查器 筛选此数据列中的事件。 有关详细信息,请参阅 使用 SQL Server Profiler 筛选跟踪
MethodName LIKE、NOT LIKE
模式 =, <>, >=, <=
NestLevel =, <>, >=, <=
NTDomainName LIKE、NOT LIKE
NTUserName LIKE、NOT LIKE
Exchange Spill =, <>, >=, <=
ObjectID2 =, <>, >=, <=
ObjectName LIKE、NOT LIKE
ObjectType =, <>, >=, <=
Offset =, <>, >=, <=
OwnerID =, <>, >=, <=
OwnerName LIKE、NOT LIKE
ParentName LIKE、NOT LIKE
权限 =, <>, >=, <=
ProviderName LIKE、NOT LIKE
Reads =, <>, >=, <=
RequestID =, <>, >=, <=
RoleName LIKE、NOT LIKE
RowCounts =, <>, >=, <=
SessionLoginName LIKE、NOT LIKE
Severity =, <>, >=, <=
SourceDatabaseID =, <>, >=, <=
SPID =, <>, >=, <=
SqlHandle 使用 SQL Server 事件探查器 筛选此数据列中的事件。 有关详细信息,请参阅 使用 SQL Server Profiler 筛选跟踪
StartTime >=, <=
State =, <>, >=, <=
成功 =, <>, >=, <=
TargetLoginName LIKE、NOT LIKE
TargetLoginSid 使用 SQL Server 事件探查器 筛选此数据列中的事件。 有关详细信息,请参阅 使用 SQL Server Profiler 筛选跟踪
TargetUserName LIKE、NOT LIKE
TextData LIKE、NOT LIKE
TransactionID =, <>, >=, <=
类型 =, <>, >=, <=
Writes =, <>, >=, <=
XactSequence =, <>, >=, <=
posted @ 2017-09-27 15:59  davidhou  阅读(541)  评论(0编辑  收藏  举报