Enabling plan capture mode with set plan dump

The set plan dump command activates and deactivates the capture of abstract plans. You can save the plans to the default group, ap_stdout, by using set plan dump with no group name:

set plan dump on

To start capturing plans in a specific abstract plan group, specify the group name. This example sets the group dev_plans as the capture group:

set plan dump dev_plans on

The group that you specify must exist before you issue the set command. The system procedure sp_add_qpgroup creates abstract plan groups; only the System Administrator or Database Owner can create an abstract plan group. Once an abstract plan group exists, any user can dump plans to the group. See “Creating a group” for information on creating a plan group.

To deactivate the capturing of plans, use:

set plan dump off

You do not need to specify a group name to end capture mode. Only one abstract plan group can be active for saving or matching abstract plans at any one time. If you are currently saving plans to a group, you must turn off the plan dump mode, and reenable it for the new group, as shown here:

set plan dump on /*save to the default group*/
go
/*some queries to be captured */
go
set plan dump off
go
set plan dump dev_plans on
go
/*additional queries*/
go

The use of the use database command while set plan dump is in effect disables plan dump mode.