Specifies the database identification number (ID) filter, or the database to include for the events specified. Microsoft® SQL Server™ captures the required information, configured by executing xp_trace_seteventclassrequired, for the specified DBID.
xp_trace_setdbidfilter {queue_handle, database_ID}
0 (success) or >1 (failure)
xp_trace_setdbidfilter returns this message:
The command(s) completed successfully.
If a database ID filter was set by executing xp_trace_setdbidfilter, xp_trace_getdbidfilter returns the database ID(s) for which the specified event class(es) will be traced.
Execute permissions for xp_trace_setdbidfilter default to members of the sysadmin fixed server role but can be granted to other users.
This example sets the database ID for the trace queue that was configured to include a database with a DBID of 17.
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_setdbidfilter @queue_handle,
17
Monitoring with SQL Server Profiler | xp_trace_getdbidfilter |
sp_helpdb | xp_trace_getqueueproperties |
xp_trace_addnewqueue | System Stored Procedures (SQL Server Profiler Extended Procedures) |
xp_trace_enumqueuehandles |