Copies one abstract plan to an abstract plan group.
sp_copy_qplan src_id, dest_group
is the ID of the abstract plan to copy.
is the name of the destination abstract plan group.
sp_copy_qplan 2140534659, ap_stdin
The destination group must exist before you can copy an abstract plan into it. You do not need to specify a source group, since plans are uniquely identified by the plan ID.
A new plan ID is generated when the plan is copied. The plan retains the ID of the user who created it, even if the system administrator or database owner copies the plan. To assign a different user ID, a system administrator or database owner can use sp_export_qpgroup and sp_import_qpgroup.
If the query text for a plan in the destination group exactly matches the query text in the source group and the user ID, the plan is not copied, and a message giving the plan IDs is sent to the user.
To copy all of the plans in an abstract plan group, use sp_copy_all_qplans.
The permission checks for sp_copy_qplans 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 execute sp_copy_qplan to copy a plan that they own. |
Granular permissions disabled |
With granular permissions disabled, you must be the database owner or a user with sa_role. Any user execute sp_copy_qplan to copy a plan that 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 |
|
System procedures sp_copy_all_qplans, sp_help_qpgroup, sp_help_qplan, sp_import_qpgroup