sp_set_qplan

Changes the text of the abstract plan of an existing plan without changing the associated query.

Syntax

sp_set_qplan id, plan

Parameters

Examples

Usage

There are additional considerations when using sp_set_qplan:
  • Use sp_set_qplan to change the abstract plan of an existing plan. You can specify a maximum of 255 characters for a plan. If the abstract plan is longer than 255 characters, drop the old plan with sp_drop_qplan, then use create plan to create a new plan for the query.

  • When you change a plan with sp_set_qplan, plans are not checked for valid abstract plan syntax and the plan is not checked for compatibility with the SQL text. Immediately check all plans modified with sp_set_qplan for correctness by running the query for the specified ID.

  • To find the ID of a plan, use sp_help_qpgroup, sp_help_qplan or sp_find_qplan. Plan IDs are also returned by create plan and are included in showplan output.

See also create plan in Reference Manual: Commands.

Permissions

The permission checks for sp_set_qplan differ based on your granular permissions settings.

SettingDescription
Enabled

With granular permissions enabled, you must be a user with manage abstract plans privilege.

Any user can execute sp_set_qplan to change the text of a plan for which they own.

Disabled

With granular permissions disabled, you must be the database owner or a user with sa_role.

Any user can execute sp_set_qplan to change the text of a plan for which they own.

Auditing

Values in event and extrainfo columns from the sysaudits table are:

InformationValues
Event

38

Audit option

exec_procedure

Command or access audited

Execution of a procedure

Information in extrainfo
  • Roles – Current active roles

  • Keywords or options – NULL

  • Previous value – NULL

  • Current value – NULL

  • Other information – All input parameters

  • Proxy information – Original login name, if set proxy in effect

Related reference
sp_drop_qpgroup
sp_drop_qplan
sp_find_qplan
sp_help_qplan