Specifies the enabling or disabling of query history using the SQL Server Profiler extended stored procedures. Query history consists of a trace of the last 100 events that occurred before a high-severity SQL Server exception. Query history traces SQL:BatchStarting, RPC:Starting and Exception events and captures all data columns. When an exception of severity 17 or greater occurs, the query history is written to the file Blackbox.trc in \Mssql7\Log.
xp_trace_setqueryhistory [[@local_variable =] value]
0 (success) or >1 (failure)
If value is specified, xp_trace_setqueryhistory returns this message:
The command(s) completed successfully.
If value is not specified, xp_trace_setqueryhistory returns this result set.
Column name | Description |
---|---|
QueryHistoryConfigValue | Whether the query history trace is configured to start on start up: 1 = True 0 = False |
QueryHistoryRunValue | Whether the query history trace is running: 1 = True 0 = False |
Execute permissions for xp_trace_setqueryhistory default to members of the sysadmin fixed server role but can be granted to other users.
DECLARE @local_variable | xp_trace_flushqueryhistory |
Monitoring with SQL Server Profiler | System Stored Procedures (SQL Server Profiler Extended Procedures) |
SET @local_variable |