sp_trace_setfilter sqlserver篩選跟蹤或跟蹤過濾

weixin_30788239發表於2020-04-05

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 =, <>, >=, <=

轉載於:https://www.cnblogs.com/davidhou/p/7602201.html

相關文章