xp_trace_setappfilter (T-SQL)

Specifies the application filter, or the applications to include or exclude for the trace specified. Microsoft® SQL Server™ captures the required information, configured by executing xp_trace_seteventclassrequired, for the included applications, if any, and does not capture the required information for the excluded applications, if any.

Syntax

xp_trace_setappfilter {queue_handle, 'include_only_applications',
    '
exclude_applications'}

Arguments
queue_handle
Is an integer that represents the handle for the trace queue. queue_handle is used to reference the trace queue and is placed in an output parameter by xp_trace_addnewqueue.
'include_only_applications'
Is a string that represents the application include filter. The application include filter indicates the applications, separated by semicolons (;), that should be considered when capturing data previously determined by sp_seteventclassrequired. The % wildcard character can be used in specifying the applications to include in the trace. If NULL, there are no restrictions on applications to include for the specified event class(es). The table shows three common applications you can choose to trace events for (these applications are included with SQL Server).

 

Value Description
MS SQLEM SQL Server Enterprise Manager
Microsoft SQL Server Query Analyzer SQL Server Query Analyzer
xpsqlweb.dll Web Assistant Wizard

'exclude_applications'
Is a string that represents the application exclude filter. The application exclude filter indicates the applications, separated by semicolons (;), that should not be considered when capturing data previously determined by sp_seteventclassrequired. The % wildcard character can be used in specifying the applications to exclude for the trace. If NULL, there are no application exclude requirements. The most common application you may choose to exclude is SQL Server Profiler itself.
Return Code Values

0 (success) or >1 (failure)

Result Sets

xp_trace_setappfilter returns this message:

The command(s) completed successfully.

  

Remarks

When you specify one or more applications to include, all other applications are excluded.


Note The event class list can be generated using xp_trace_geteventnames.


Permissions

Execute permissions for xp_trace_setappfilter default to members of the sysadmin fixed server role but can be granted to other users.

Examples
A. Include only SQL Server Query Analyzer and SQL Server Enterprise Manager

This example executes xp_trace_setappfilter to include events from SQL Server Query Analyzer and SQL Server Enterprise Manager.

USE master

DECLARE @queue_handle int, @column_value int

SET @column_value = 16|32|8192|128|512

EXEC xp_trace_addnewqueue 1000,

    5,

    95,

    90,

    @column_value,

    @queue_handle OUTPUT

EXEC xp_trace_setappfilter @queue_handle,

    'Microsoft SQL Server Query Ana%;MS SQLEM%',

    NULL

  

B. Include only SQL Server Query Analyzer and exclude SQL Server Profiler

This example executes xp_trace_setappfilter to only include events from SQL Server Query Analyzer.

USE master

DECLARE @queue_handle int, @column_value int

SET @column_value = 16|32|8192|128|512

EXEC xp_trace_addnewqueue 1000,

    5,

    95,

    90,

    @column_value,

    @queue_handle OUTPUT

EXEC xp_trace_setappfilter @queue_handle,

    'Microsoft SQL Server Query Ana%',

    'SQL Server Profiler%'

  

See Also
Monitoring with SQL Server Profiler xp_trace_getappfilter
xp_trace_addnewqueue xp_trace_getqueueproperties
xp_trace_enumqueuehandles System Stored Procedures (SQL Server Profiler Extended Procedures)

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.