Changes the text of the abstract plan of an existing plan without changing the associated query.
sp_set_qplan id, plan
is the ID of the abstract plan.
is a new abstract plan.
sp_set_qplan 563789159, "( g_join (scan t1) (scan t2))"
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.
The permission checks for sp_set_qplan differ based on your granular permissions settings.
Granular permissions 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. |
Granular permissions 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. |
Values in event and extrainfo columns from the sysaudits table are:
Event |
Audit option |
Command or access audited |
Information in extrainfo |
---|---|---|---|
38 |
exec_procedure |
Execution of a procedure |
|
Commands create plan
System procedures sp_drop_qpgroup, sp_drop_qplan, sp_find_qplan, sp_help_qplan