xp_trace_setserverfilter (T-SQL)

Specifies the Microsoft® SQL Server™ name filter, or the SQL Server names to include or exclude for the events specified. SQL Server captures the required information, configured by executing xp_trace_seteventclassrequired, for the included server names, if any, and does not capture the required information for the excluded server names, if any. Any SQL Server name can be specified.

Syntax

xp_trace_setserverfilter {queue_handle, 'include_servers',
    '
exclude_servers'}

Arguments
queue_handle
Is an integer representing the handle for the trace queue. queue_handle is used to reference the trace queue and placed in an output parameter by xp_trace_addnewqueue.
'include_servers'
Is a string value representing the SQL Server name include filter. The server name include filter indicates the SQL Servers, separated by semicolons (;), that should be considered when capturing data previously determined by sp_seteventclassrequired. The % wildcard character can be used in specifying the SQL Servers to include in the trace. If NULL is passed, there are no restrictions on servers to include for the specified event classes.
'exclude_servers'
Is a string value representing the SQL Server name exclude filter. The server name exclude filter indicates the SQL Servers, 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 SQL Servers to exclude in the trace. If NULL is passed, there are no excluded servers for the specified event classes.
Return Code Values

0 (success) or >1 (failure)

Result Sets

xp_trace_setserverfilter returns this message:

The command(s) completed successfully.

  

Remarks

Generate the event class list by executing xp_trace_geteventnames.

When you specify one or more SQL Server names to include, all other server names are excluded.

Permissions

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

Examples

This example configures the server filter value information for the trace queue. Servers included are those with LONDON in the server name, and servers excluded are those with SEATTLE in the server name.

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_setserverfilter @queue_handle,

    'LONDON%',

    'SEATTLE%'

  

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

  


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