Specifies the trace queue destination filter, or the destination for the events specified. Microsoft® SQL Server™ captures the required information, configured by executing xp_trace_seteventclassrequired, and sends the captured information to the specified destination.
xp_trace_setqueuedestination
{
queue_handle, destination, value
{[, 'server'] [, 'object'] }
}
Value | Description |
---|---|
2 | To file |
3 | To application log |
4 | To table |
5 | To forwarded server |
If multiple destinations are required, xp_trace_setqueuedestination can be called multiple times. Here are some guidelines for working with destinations:
Note Files created by xp_trace_setqueuedestination have the trace file format. To see a trace file from the SQL Server Profiler graphical interface, open the file as a trace file rather than as an SQL script.
0 (success) or >1 (failure)
xp_trace_setqueuedestination returns this message:
The command(s) completed successfully.
Assume there are two servers: S1 and S2. If a client (named client) writes to a table on server S2 from server S1, server S2 sees the security context of server S1. In future releases of Microsoft Windows NT®, server S2 will see the security context of the client rather than of server S1.
Forwarding is a process that involves two or more servers and allows traced events from one or more servers to be forwarded to a designated main SQL Server. Before enabling forwarding, the trace queue must be created on the originating computer. Then, forwarding (by using destination) can be enabled. In addition, the required data must include the server name.
All events captured by the main, managing SQL Server get compiled into one master list of events, which is prefaced by the originating server name. This compiled event list is useful for minimizing storage space because there is only one file to store rather than two or more (each server, without forwarding, stores its own event file). Forwarding can also assist in load balancing and central server administration because one central server can be monitored rather than many individual servers.
Here are some guidelines for using forwarding:
Execute permissions for xp_trace_setqueuedestination default to members of the sysadmin fixed server role but can be granted to other users.
This example sends the trace queue information to both a file and a table.
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_setqueuedestination @queue_handle,
2,
0,
NULL,
'c:\myfile.txt'
EXEC xp_trace_setqueuedestination @queue_handle,
4,
0,
'SEATTLE2',
'mytable'
Monitoring with SQL Server Profiler | xp_trace_getqueueproperties |
xp_trace_addnewqueue | xp_trace_startconsumer |
xp_trace_enumqueuehandles | System Stored Procedures (SQL Server Profiler Extended Procedures) |
xp_trace_getqueuedestination |